結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー atuk721atuk721
提出日時 2017-02-11 21:41:31
言語 Haskell
(9.8.2)
結果
AC  
実行時間 652 ms / 2,000 ms
コード長 2,070 bytes
コンパイル時間 1,834 ms
コンパイル使用メモリ 167,740 KB
実行使用メモリ 16,408 KB
最終ジャッジ日時 2023-08-28 14:46:35
合計ジャッジ時間 8,489 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,128 KB
testcase_01 AC 3 ms
7,156 KB
testcase_02 AC 2 ms
7,116 KB
testcase_03 AC 62 ms
12,696 KB
testcase_04 AC 61 ms
12,504 KB
testcase_05 AC 413 ms
14,352 KB
testcase_06 AC 392 ms
15,464 KB
testcase_07 AC 273 ms
13,692 KB
testcase_08 AC 212 ms
13,748 KB
testcase_09 AC 542 ms
15,728 KB
testcase_10 AC 32 ms
12,144 KB
testcase_11 AC 92 ms
12,700 KB
testcase_12 AC 112 ms
13,072 KB
testcase_13 AC 412 ms
14,300 KB
testcase_14 AC 632 ms
15,500 KB
testcase_15 AC 102 ms
13,152 KB
testcase_16 AC 32 ms
11,936 KB
testcase_17 AC 82 ms
12,732 KB
testcase_18 AC 22 ms
11,768 KB
testcase_19 AC 472 ms
16,408 KB
testcase_20 AC 652 ms
15,452 KB
testcase_21 AC 102 ms
13,084 KB
testcase_22 AC 112 ms
13,076 KB
testcase_23 AC 152 ms
13,116 KB
testcase_24 AC 463 ms
15,540 KB
testcase_25 AC 583 ms
15,564 KB
testcase_26 AC 262 ms
14,036 KB
testcase_27 AC 223 ms
14,032 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import qualified Control.Monad as M
import qualified Data.Char as C
import qualified Data.List as L

type Result = (String, ([Int], Int))
type Answer = (Char, Int)

main :: IO ()
main = do
  examN <- readLn :: IO Int
  levels <- fmap (map read . words) getLine :: IO [Int]
  submitN <- readLn :: IO Int
  submits <- fmap lines getContents

  let answers = zip (take examN ['A'..]) $ repeat 0
      result = proc [] answers levels examN submits

  M.forM_ (zip [1..] result) $ \(n, (name, (scores, s))) -> do
    putStrLn $ show n ++ " " ++ name ++ " " ++ (unwords $ map show scores) ++ " " ++ show s

getLevel :: [Int] -> Char -> (Int, Int)
getLevel levels c = (index, levels !! index)
  where index = C.ord c - 65

proc :: [Result] -> [Answer] -> [Int] -> Int -> [String] -> [Result]
proc rs _ _ _ [] = rs
proc rs as ls examN (z:zs) = proc rs'' as' ls examN zs
                          where [name, levelC:[]] = words z
                                (levelIndex, level) = getLevel ls levelC
                                order = case lookup levelC as of
                                          Just x -> x + 1
                                          Nothing -> 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 of
                                            Just 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 == -1
                                         then rs ++ [(name, (ss', sum ss'))]
                                         else take i rs ++ (name, (ss', sum ss')) : (drop (i + 1) rs)
                                rs'' = L.sortOn (\(_, (_, s)) -> (-s)) rs'
0