結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー atuk721atuk721
提出日時 2017-02-11 21:44:42
言語 Haskell
(9.8.2)
結果
AC  
実行時間 361 ms / 2,000 ms
コード長 2,091 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 176,988 KB
実行使用メモリ 13,952 KB
最終ジャッジ日時 2024-06-09 09:57:45
合計ジャッジ時間 6,952 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 38 ms
9,344 KB
testcase_04 AC 36 ms
9,216 KB
testcase_05 AC 216 ms
10,624 KB
testcase_06 AC 234 ms
11,648 KB
testcase_07 AC 155 ms
10,880 KB
testcase_08 AC 122 ms
10,624 KB
testcase_09 AC 295 ms
10,880 KB
testcase_10 AC 19 ms
8,704 KB
testcase_11 AC 52 ms
9,472 KB
testcase_12 AC 63 ms
9,600 KB
testcase_13 AC 228 ms
10,752 KB
testcase_14 AC 346 ms
12,416 KB
testcase_15 AC 67 ms
9,728 KB
testcase_16 AC 19 ms
8,704 KB
testcase_17 AC 54 ms
9,728 KB
testcase_18 AC 14 ms
8,192 KB
testcase_19 AC 272 ms
13,952 KB
testcase_20 AC 361 ms
12,800 KB
testcase_21 AC 58 ms
9,600 KB
testcase_22 AC 61 ms
9,600 KB
testcase_23 AC 94 ms
9,728 KB
testcase_24 AC 248 ms
12,032 KB
testcase_25 AC 320 ms
12,928 KB
testcase_26 AC 148 ms
10,880 KB
testcase_27 AC 127 ms
10,624 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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

ソースコード

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