結果

問題 No.447 ゆきこーだーの雨と雪 (2)
ユーザー Ysmr_RyYsmr_Ry
提出日時 2016-12-23 19:49:19
言語 Haskell
(9.8.2)
結果
AC  
実行時間 1,871 ms / 2,000 ms
コード長 1,564 bytes
コンパイル時間 9,034 ms
コンパイル使用メモリ 198,608 KB
実行使用メモリ 22,200 KB
最終ジャッジ日時 2023-08-21 07:39:07
合計ジャッジ時間 21,986 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,700 KB
testcase_01 AC 3 ms
7,868 KB
testcase_02 AC 3 ms
7,776 KB
testcase_03 AC 23 ms
13,848 KB
testcase_04 AC 32 ms
14,196 KB
testcase_05 AC 1,543 ms
17,424 KB
testcase_06 AC 813 ms
18,896 KB
testcase_07 AC 92 ms
16,208 KB
testcase_08 AC 272 ms
15,528 KB
testcase_09 AC 1,422 ms
20,328 KB
testcase_10 AC 23 ms
13,092 KB
testcase_11 AC 32 ms
15,824 KB
testcase_12 AC 92 ms
14,568 KB
testcase_13 AC 1,032 ms
17,764 KB
testcase_14 AC 1,871 ms
20,408 KB
testcase_15 AC 42 ms
15,952 KB
testcase_16 AC 32 ms
13,088 KB
testcase_17 AC 32 ms
15,828 KB
testcase_18 AC 12 ms
12,252 KB
testcase_19 AC 1,043 ms
21,380 KB
testcase_20 AC 1,672 ms
21,064 KB
testcase_21 AC 43 ms
14,804 KB
testcase_22 AC 32 ms
13,812 KB
testcase_23 AC 42 ms
16,056 KB
testcase_24 AC 292 ms
20,472 KB
testcase_25 AC 632 ms
22,200 KB
testcase_26 AC 73 ms
16,472 KB
testcase_27 AC 62 ms
16,324 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 Control.Applicative ((<$>))
import Control.Arrow (second)
import Control.Monad
import Control.Monad.State
import Data.Char (ord)
import Data.List (elemIndices, sortBy)
import Data.Function (on)
import Data.Monoid ((<>))
import qualified Data.Array as A
import qualified Data.Map as M

type Submission = (String, Int)
type AcCnt = M.Map Int Int

main :: IO ()
main = do
  n <- readLn
  ls <- map read . words <$> getLine
  t <- readLn
  subs <- replicateM t $ do
    [name, p] <- words <$> getLine
    return (name, ord (head p)-ord 'A')
  let upds = map (second A.elems) $ M.toList $ evalState (proc subs ls n) $ M.fromList $ zip [0..n-1] $ repeat 1
  forM_ (zip [1..] (sortBy (comp subs) upds)) $ \(i, (name, xs)) -> do
    putStr $ show i ++ " " ++ name
    mapM_ (putStr . (" "++) . show) xs
    putStrLn $ " " ++ show (sum xs)

proc :: [Submission] -> [Double] -> Int -> State AcCnt (M.Map String (A.Array Int Int))
proc [] _ _ = return M.empty
proc ((name, p):xs) ls n = do
  acCnt <- get
  let pts = evalState (proc xs ls n) (M.insert p (acCnt M.! p+1) acCnt)
      pts' = if name `M.notMember` pts then M.insert name (A.listArray (0, n-1) $ repeat 0) pts else pts
  return $ M.insert name (pts' M.! name A.// [(p, floor $ 50*(ls!!p)+50*(ls!!p)/(0.8+0.2*fromIntegral (acCnt M.! p)))]) pts'

comp :: [Submission] -> (String, [Int]) -> (String, [Int]) -> Ordering
comp subs (lName, l) (rName, r) = (compare `on` sum) r l <> idxL `compare` idxR
  where
    idxL = last $ elemIndices lName $ map fst subs
    idxR = last $ elemIndices rName $ map fst subs
0