結果
問題 | No.447 ゆきこーだーの雨と雪 (2) |
ユーザー | atuk721 |
提出日時 | 2017-02-13 05:10:06 |
言語 | Haskell (9.8.2) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,041 bytes |
コンパイル時間 | 1,262 ms |
コンパイル使用メモリ | 200,576 KB |
実行使用メモリ | 22,076 KB |
最終ジャッジ日時 | 2023-08-28 15:03:12 |
合計ジャッジ時間 | 3,882 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 2 ms
7,700 KB |
testcase_02 | AC | 3 ms
7,680 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
ソースコード
import qualified Control.Monad as Mo import qualified Control.Monad.State as S import qualified Data.Char as C import qualified Data.Ord as O 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 compareResult 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' compareResult :: (String, ([Int], [Int])) -> (String, ([Int], [Int])) -> Ordering compareResult (_, (ss, o)) (_, (ss', o')) = O.comparing head o o' where c = O.comparing sum ss' ss