You are viewing a single comment's thread. Return to all comments →
Haskell
module Main where import Control.Monad (replicateM) import Data.List (partition, sortBy, splitAt) solve :: Int -> [[Int]] -> Int solve k trials = sum pluses - sum minuses + sum uvals where (important, unimportant) = partition (\(_ : t : _) -> t == 1) trials ivals = sortBy (flip compare) $ map head important uvals = map head unimportant (pluses, minuses) = splitAt k ivals main :: IO () main = do [n, k] <- fmap (map read . words) getLine :: IO [Int] trials <- replicateM n $ fmap (map read . words) getLine :: IO [[Int]] print $ solve k trials
Seems like cookies are disabled on this browser, please enable them to open this website
Luck Balance
You are viewing a single comment's thread. Return to all comments →
Haskell