結果

問題 No.662 スロットマシーン
ユーザー ducktailducktail
提出日時 2018-08-26 14:50:02
言語 Haskell
(9.6.2)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 938 bytes
コンパイル時間 1,875 ms
コンパイル使用メモリ 165,944 KB
実行使用メモリ 14,068 KB
最終ジャッジ日時 2023-09-13 19:19:20
合計ジャッジ時間 3,414 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,844 KB
testcase_01 AC 3 ms
7,860 KB
testcase_02 AC 3 ms
7,984 KB
testcase_03 AC 3 ms
8,308 KB
testcase_04 AC 4 ms
9,196 KB
testcase_05 AC 2 ms
8,132 KB
testcase_06 AC 4 ms
9,852 KB
testcase_07 AC 4 ms
9,984 KB
testcase_08 AC 12 ms
12,892 KB
testcase_09 AC 12 ms
14,048 KB
testcase_10 AC 12 ms
13,992 KB
testcase_11 AC 12 ms
14,068 KB
testcase_12 AC 12 ms
13,908 KB
testcase_13 AC 12 ms
14,052 KB
testcase_14 AC 12 ms
13,940 KB
testcase_15 AC 12 ms
14,032 KB
testcase_16 AC 3 ms
7,880 KB
testcase_17 AC 12 ms
13,948 KB
testcase_18 AC 12 ms
13,984 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.Monad
import Data.Map (Map)
import qualified Data.Map as M

main :: IO ()
main = do
  cns <- replicateM 5 (f <$> getLine)
  n1 <- readLn
  ma <- M.fromListWith (+) <$> replicateM n1 (g <$> getLine)
  n2 <- readLn
  mb <- M.fromListWith (+) <$> replicateM n2 (g <$> getLine)
  n3 <- readLn
  mc <- M.fromListWith (+) <$> replicateM n3 (g <$> getLine)
  prt $ solve cns (n1*n2*n3) ma mb mc
  where
    f = (\[str, coin] -> (str, read coin)) . words
    g s = (s, 1)

solve :: [(String, Int)] -> Int -> Map String Int -> Map String Int -> Map String Int -> (Double, [Int])
solve cns n ma mb mc = (exp, cts)
  where
    exp = (fromIntegral $ sum $ zipWith g cts cns) / fromIntegral n
    cts = map f cns
    f (s, _) = M.findWithDefault 0 s ma * M.findWithDefault 0 s mb * M.findWithDefault 0 s mc * 5
    g c (_,p) = c * p

prt :: (Double, [Int]) -> IO ()
prt (e,ps) = do
  print e
  mapM_ print ps
0