結果

問題 No.662 スロットマシーン
ユーザー pekempeypekempey
提出日時 2018-03-10 16:05:15
言語 Haskell
(9.8.2)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 798 bytes
コンパイル時間 10,369 ms
コンパイル使用メモリ 172,032 KB
実行使用メモリ 10,368 KB
最終ジャッジ日時 2024-04-21 14:29:24
合計ジャッジ時間 7,584 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 4 ms
6,944 KB
testcase_08 AC 10 ms
9,088 KB
testcase_09 AC 11 ms
9,984 KB
testcase_10 AC 12 ms
10,240 KB
testcase_11 AC 11 ms
10,368 KB
testcase_12 AC 12 ms
10,240 KB
testcase_13 AC 13 ms
9,984 KB
testcase_14 AC 11 ms
10,112 KB
testcase_15 AC 12 ms
10,112 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 12 ms
10,112 KB
testcase_18 AC 12 ms
10,112 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 Data.List
import Data.Maybe
import Control.Monad

main = do
  dic <- replicateM 5 readKV
  (n1, a) <- readReel (map fst dic)
  (n2, b) <- readReel (map fst dic)
  (n3, c) <- readReel (map fst dic)

  -- [0] [1] [2] [3] [4]
  -- 000         0     0
  --     000      0   0
  --         000   0 0

  let cnt = map (\k -> let x = a!!k; y = b!!k; z = c!!k in 5*x*y*z) $ [0..4]
  let ans = sum $ zipWith (*) cnt (map snd dic)

  print $ fromIntegral ans / fromIntegral (n1 * n2 * n3)
  mapM_ print cnt


readKV :: IO (String, Int)
readKV = do
  [k, v] <- words <$> getLine
  return (k, read v)

readReel :: [String] -> IO (Int, [Int])
readReel dic = do
  n <- readLn :: IO Int
  x <- replicateM n (fromJust . flip elemIndex dic <$> getLine)
  return (n, [length . filter (==i) $ x | i <- [0..4]])
0