結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー atuk721atuk721
提出日時 2017-02-11 21:41:31
言語 Haskell
(9.8.2)
結果
AC  
実行時間 664 ms / 2,000 ms
コード長 2,070 bytes
コンパイル時間 3,862 ms
コンパイル使用メモリ 176,000 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-06-09 09:58:00
合計ジャッジ時間 11,400 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 58 ms
9,088 KB
testcase_04 AC 53 ms
9,216 KB
testcase_05 AC 408 ms
10,880 KB
testcase_06 AC 395 ms
11,776 KB
testcase_07 AC 270 ms
10,368 KB
testcase_08 AC 206 ms
10,368 KB
testcase_09 AC 555 ms
12,416 KB
testcase_10 AC 28 ms
8,832 KB
testcase_11 AC 84 ms
9,344 KB
testcase_12 AC 106 ms
9,600 KB
testcase_13 AC 414 ms
10,880 KB
testcase_14 AC 639 ms
12,288 KB
testcase_15 AC 97 ms
9,728 KB
testcase_16 AC 25 ms
8,576 KB
testcase_17 AC 79 ms
9,728 KB
testcase_18 AC 21 ms
8,448 KB
testcase_19 AC 472 ms
13,312 KB
testcase_20 AC 664 ms
12,032 KB
testcase_21 AC 92 ms
9,728 KB
testcase_22 AC 101 ms
9,856 KB
testcase_23 AC 150 ms
9,856 KB
testcase_24 AC 456 ms
12,928 KB
testcase_25 AC 591 ms
12,672 KB
testcase_26 AC 254 ms
10,752 KB
testcase_27 AC 221 ms
10,880 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.sortOn (\(_, (_, s)) -> (-s)) rs'
0