結果
問題 | No.662 スロットマシーン |
ユーザー | ducktail |
提出日時 | 2018-08-26 14:47:11 |
言語 | Haskell (9.6.2) |
結果 |
RE
|
実行時間 | - |
コード長 | 938 bytes |
コンパイル時間 | 4,149 ms |
コンパイル使用メモリ | 162,700 KB |
実行使用メモリ | 14,060 KB |
最終ジャッジ日時 | 2023-09-13 19:18:47 |
合計ジャッジ時間 | 4,593 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,928 KB |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | RE | - |
testcase_05 | AC | 3 ms
8,068 KB |
testcase_06 | RE | - |
testcase_07 | RE | - |
testcase_08 | RE | - |
testcase_09 | AC | 13 ms
13,980 KB |
testcase_10 | AC | 12 ms
13,964 KB |
testcase_11 | AC | 12 ms
14,024 KB |
testcase_12 | AC | 12 ms
13,992 KB |
testcase_13 | AC | 12 ms
14,056 KB |
testcase_14 | AC | 12 ms
14,060 KB |
testcase_15 | AC | 12 ms
13,948 KB |
testcase_16 | AC | 2 ms
7,968 KB |
testcase_17 | AC | 12 ms
13,992 KB |
testcase_18 | AC | 12 ms
13,988 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
ソースコード
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 n1 (g <$> getLine) n3 <- readLn mc <- M.fromListWith (+) <$> replicateM n1 (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