結果
問題 | No.24 数当てゲーム |
ユーザー | guricerin |
提出日時 | 2020-01-12 21:14:03 |
言語 | F# (F# 4.0) |
結果 |
AC
|
実行時間 | 64 ms / 5,000 ms |
コード長 | 1,317 bytes |
コンパイル時間 | 4,973 ms |
コンパイル使用メモリ | 164,792 KB |
実行使用メモリ | 24,492 KB |
最終ジャッジ日時 | 2023-08-20 07:43:13 |
合計ジャッジ時間 | 6,480 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 64 ms
22,540 KB |
testcase_01 | AC | 64 ms
22,468 KB |
testcase_02 | AC | 63 ms
24,380 KB |
testcase_03 | AC | 64 ms
24,428 KB |
testcase_04 | AC | 63 ms
22,492 KB |
testcase_05 | AC | 64 ms
22,320 KB |
testcase_06 | AC | 64 ms
22,472 KB |
testcase_07 | AC | 64 ms
22,576 KB |
testcase_08 | AC | 64 ms
24,492 KB |
testcase_09 | AC | 63 ms
22,476 KB |
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0 Copyright (c) Microsoft Corporation. All Rights Reserved.
ソースコード
open System open System.Collections.Generic [<AutoOpen>] module Cin = let read f = stdin.ReadLine() |> f let reada f = stdin.ReadLine().Split() |> Array.map f let readChars() = read string |> Seq.toArray let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString())) [<AutoOpen>] module Cout = let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput())) let print (s: string) = writer.Write s let println (s: string) = writer.WriteLine s let inline puts (s: ^a) = string s |> println let main() = let n = read int let mp = Array.init 10 (fun i -> (true, 0)) for i in 0 .. n - 1 do let s = reada string let yn = s.[4] let xs = Array.map (fun x -> Convert.ToInt32(x.ToString())) s.[0..3] match yn with | "YES" -> xs |> Array.iter (fun x -> let (b, c) = mp.[x] mp.[x] <- (b, c + 1)) | _ -> xs |> Array.iter (fun x -> let (b, c) = mp.[x] mp.[x] <- (false, c)) mp |> Array.indexed |> Array.map (fun (i, (b, c)) -> if b then (i, c) else (i, -1)) |> Array.maxBy (fun (i, c) -> c) |> fun (i, c) -> i |> puts () main() writer.Close()