結果
問題 | No.447 ゆきこーだーの雨と雪 (2) |
ユーザー |
![]() |
提出日時 | 2017-02-11 21:41:31 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 702 ms / 2,000 ms |
コード長 | 2,070 bytes |
コンパイル時間 | 2,382 ms |
コンパイル使用メモリ | 176,048 KB |
実行使用メモリ | 13,440 KB |
最終ジャッジ日時 | 2024-12-29 16:37:25 |
合計ジャッジ時間 | 10,501 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
importqualifiedControl.MonadasMimportqualifiedData.CharasCimportqualifiedData.ListasLtype Result = (String, ([Int], Int))type Answer = (Char, Int)main::IO()main = doexamN <- readLn :: IO Intlevels <- fmap (map read . words) getLine :: IO [Int]submitN <- readLn :: IO Intsubmits <- fmap lines getContentslet answers = zip (take examN ['A'..]) $ repeat 0result = proc [] answers levels examN submitsM.forM_ (zip [1..] result) $ \(n, (name, (scores, s))) -> doputStrLn $ show n ++ " " ++ name ++ " " ++ (unwords $ map show scores) ++ " " ++ show sgetLevel::Int->Char->IntIntgetLevel levels c = (index, levels !! index)where index = C.ord c - 65proc::Result->Answer->Int->Int->String->Resultproc rs _ _ _ [] = rsproc rs as ls examN (z:zs) = proc rs'' as' ls examN zswhere [name, levelC:[]] = words z(levelIndex, level) = getLevel ls levelCorder = case lookup levelC as ofJust x -> x + 1Nothing -> error "No level"score = floor $ 50 * (realToFrac level) + 50 * (realToFrac level) / (0.8 + 0.2 * (realToFrac order))(i, ss) = case L.findIndex (\(n, _) -> n == name) rs ofJust i -> (i, fst . snd $ rs !! i)Nothing -> (-1, replicate examN 0)ss' = take levelIndex ss ++ (score : drop (levelIndex + 1) ss)as' = take levelIndex as ++ ((levelC, order) : drop (levelIndex + 1) as)rs' = if i == -1then rs ++ [(name, (ss', sum ss'))]else take i rs ++ (name, (ss', sum ss')) : (drop (i + 1) rs)rs'' = L.sortOn (\(_, (_, s)) -> (-s)) rs'