結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー atuk721atuk721
提出日時 2017-02-11 21:44:42
言語 Haskell
(9.8.2)
結果
AC  
実行時間 412 ms / 2,000 ms
コード長 2,091 bytes
コンパイル時間 977 ms
コンパイル使用メモリ 164,048 KB
実行使用メモリ 16,548 KB
最終ジャッジ日時 2023-08-28 14:46:14
合計ジャッジ時間 7,024 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,068 KB
testcase_01 AC 3 ms
7,212 KB
testcase_02 AC 2 ms
7,144 KB
testcase_03 AC 52 ms
12,788 KB
testcase_04 AC 42 ms
12,508 KB
testcase_05 AC 252 ms
13,772 KB
testcase_06 AC 262 ms
14,936 KB
testcase_07 AC 182 ms
14,264 KB
testcase_08 AC 142 ms
13,960 KB
testcase_09 AC 342 ms
14,236 KB
testcase_10 AC 32 ms
11,944 KB
testcase_11 AC 62 ms
12,896 KB
testcase_12 AC 82 ms
13,124 KB
testcase_13 AC 262 ms
14,340 KB
testcase_14 AC 392 ms
15,116 KB
testcase_15 AC 72 ms
12,788 KB
testcase_16 AC 22 ms
11,980 KB
testcase_17 AC 62 ms
12,832 KB
testcase_18 AC 22 ms
11,684 KB
testcase_19 AC 302 ms
16,548 KB
testcase_20 AC 412 ms
15,364 KB
testcase_21 AC 73 ms
12,984 KB
testcase_22 AC 72 ms
12,776 KB
testcase_23 AC 112 ms
13,240 KB
testcase_24 AC 293 ms
14,688 KB
testcase_25 AC 372 ms
15,560 KB
testcase_26 AC 173 ms
14,264 KB
testcase_27 AC 152 ms
13,812 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.sortBy (\(_, (_, s)) (_, (_, s')) -> compare s' s) rs'
0