結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー atuk721atuk721
提出日時 2017-02-13 04:52:45
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 1,872 bytes
コンパイル時間 4,589 ms
コンパイル使用メモリ 198,544 KB
実行使用メモリ 20,588 KB
最終ジャッジ日時 2023-08-28 15:00:31
合計ジャッジ時間 7,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
7,624 KB
testcase_02 AC 3 ms
7,580 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Mo
import qualified Control.Monad.State as S
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M

type Order = M.Map String ([Int], [Int])
type Answer = M.Map Char Int
data ProcState = ProcState {order :: Order, answer :: Answer} deriving Show

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 = M.fromList $ zip (take examN ['A'..]) $ repeat 0
      resultS = Mo.forM (zip [1..] submits) $ \d -> do
        s <- S.get
        let o = order s
            a = answer s
            count = fst d
            [name, levelC:[]] = words $ snd d
            (levelIndex, level) = getLevel levels levelC
            rank = (M.!) a levelC + 1
            score = floor $ 50 * (realToFrac level) + 50 * (realToFrac level) / (0.8 + 0.2 * (realToFrac rank))
            (scores, answers) = case M.lookup name o of
                                  Just (ss, as) -> (ss, as)
                                  Nothing -> (replicate examN 0, [])
            scores' = take levelIndex scores ++ (score : drop (levelIndex + 1) scores)
            o' = M.insert name (scores', count:answers) o
            a' = M.insert levelC rank a
        S.put $ ProcState o' a'

      result = M.toList . order . S.execState resultS $ ProcState M.empty answers
      result' = L.sortBy (\(n, (ss, o)) (n', (ss', o')) -> compare (sum ss') (sum ss') `mappend` compare (head o) (head o')) result

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

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