結果

問題 No.662 スロットマシーン
ユーザー taktak
提出日時 2018-03-16 14:04:53
言語 F#
(F# 4.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 1,271 bytes
コンパイル時間 3,592 ms
コンパイル使用メモリ 164,368 KB
実行使用メモリ 27,164 KB
最終ジャッジ日時 2023-08-23 11:48:11
合計ジャッジ時間 6,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
27,008 KB
testcase_01 AC 104 ms
24,948 KB
testcase_02 AC 102 ms
24,992 KB
testcase_03 AC 102 ms
24,944 KB
testcase_04 AC 101 ms
25,088 KB
testcase_05 AC 101 ms
24,916 KB
testcase_06 AC 102 ms
26,980 KB
testcase_07 AC 104 ms
24,964 KB
testcase_08 AC 105 ms
27,080 KB
testcase_09 AC 109 ms
24,996 KB
testcase_10 AC 108 ms
27,060 KB
testcase_11 AC 107 ms
27,164 KB
testcase_12 AC 107 ms
25,028 KB
testcase_13 AC 107 ms
24,912 KB
testcase_14 AC 107 ms
25,064 KB
testcase_15 AC 107 ms
24,984 KB
testcase_16 AC 103 ms
25,044 KB
testcase_17 AC 108 ms
26,984 KB
testcase_18 AC 110 ms
26,964 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System
open System.Collections.Generic

let read() = Console.ReadLine()
let readInt() = read() |> int

let make() =
    let num = readInt()
    let arr = Array.init num (fun _ -> read())
    num,arr

let cnt keys arr =
    let t = new Dictionary<string,int64>()
    for k in keys do 
        t.[k] <- 0L
    for v in arr do 
        t.[v] <- t.[v] + 1L
    t

let scores = 
    let t = new Dictionary<string,int64>()
    for i in 1..5 do 
        let tt = Console.ReadLine().Split()
        t.[tt.[0]] <- tt.[1] |> int64
    t

[<EntryPoint>]
let main _ =
    let n1,A = make()
    let n2,B = make()
    let n3,C = make()
    let cnt0 = cnt scores.Keys
    let cntA = cnt0 A
    let cntB = cnt0 B
    let cntC = cnt0 C

    let occurrences = 
        let t = new  Dictionary<string,int64>()
        for k in scores.Keys do 
            t.[k] <- 0L
        t

    let mutable sum = 0L
    for k in scores.Keys do
        let occur = cntA.[k] * cntB.[k] * cntC.[k] * 5L
        if occur <> 0L then
            sum <- sum + int64 occur * int64 scores.[k]
            occurrences.[k] <- occurrences.[k] + occur

    float sum / (float n1 * float n2 * float n3)
    |> printfn "%f"

    scores.Keys
    |> seq
    |> Seq.iter(fun k -> printfn "%i" occurrences.[k])

    0
0