結果

問題 No.706 多眼生物の調査
ユーザー nobigomunobigomu
提出日時 2018-07-02 17:50:09
言語 F#
(F# 4.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 577 bytes
コンパイル時間 5,468 ms
コンパイル使用メモリ 161,596 KB
実行使用メモリ 26,112 KB
最終ジャッジ日時 2023-09-13 16:57:21
合計ジャッジ時間 7,265 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
23,996 KB
testcase_01 AC 118 ms
24,000 KB
testcase_02 AC 116 ms
24,060 KB
testcase_03 AC 112 ms
23,912 KB
testcase_04 AC 115 ms
26,112 KB
testcase_05 AC 117 ms
25,964 KB
testcase_06 AC 119 ms
26,080 KB
testcase_07 AC 115 ms
23,860 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

ソースコード

diff #

open System.Collections.Generic

let getV (d:Dictionary<_,_>) k =
    match d.TryGetValue(k) with
    | true, n -> n+1
    | _ -> 1

let init (d:Dictionary<_,_>) =
    seq { for _ in 1..(stdin.ReadLine() |> int) -> stdin.ReadLine().Length }
    |> Seq.iter (fun k -> d.[k] <- getV d k)

let pred a b =
    if (snd a)=(snd b) && (fst a)<(fst b) || (snd a)<(snd b) then b else a

let f () =
    let d = Dictionary<int,int>()
    init d |> ignore
    seq { for e in d -> (e.Key,e.Value) }
    |> Seq.fold (fun a e -> pred a e) (0,0)
    |> fun e -> fst e - 2

f () |> printfn "%A"
0