You are viewing a single comment's thread. Return to all comments →
Haskell:
module Main where import Control.Monad (replicateM_) solve :: Int -> Int -> Int -> Int -> Int -> Int solve b w bc wc z | bc > wc + z = (b + w) * wc + b * z | wc > bc + z = (b + w) * bc + w * z | otherwise = b * bc + w * wc main :: IO () main = do cases <- readLn :: IO Int replicateM_ cases $ do [b, w] <- map read . words <$> getLine [bc, wc, z] <- map read . words <$> getLine print $ solve b w bc wc z
Seems like cookies are disabled on this browser, please enable them to open this website
Taum and B'day
You are viewing a single comment's thread. Return to all comments →
Haskell: