結果

問題 No.628 Tagの勢い
ユーザー natoriusannatoriusan
提出日時 2023-08-01 13:51:45
言語 F#
(F# 4.0)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 662 bytes
コンパイル時間 17,416 ms
コンパイル使用メモリ 204,736 KB
実行使用メモリ 37,288 KB
最終ジャッジ日時 2024-04-19 13:11:28
合計ジャッジ時間 13,270 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 310 ms
34,684 KB
testcase_01 AC 310 ms
34,288 KB
testcase_02 AC 323 ms
34,884 KB
testcase_03 AC 318 ms
34,608 KB
testcase_04 AC 315 ms
34,748 KB
testcase_05 AC 310 ms
34,432 KB
testcase_06 AC 326 ms
34,992 KB
testcase_07 AC 312 ms
34,716 KB
testcase_08 AC 312 ms
34,760 KB
testcase_09 AC 311 ms
34,492 KB
testcase_10 AC 327 ms
34,452 KB
testcase_11 AC 317 ms
34,268 KB
testcase_12 AC 326 ms
36,868 KB
testcase_13 AC 318 ms
37,288 KB
testcase_14 AC 328 ms
36,764 KB
testcase_15 AC 326 ms
36,764 KB
testcase_16 AC 318 ms
35,268 KB
testcase_17 AC 318 ms
34,560 KB
testcase_18 AC 311 ms
34,736 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (379 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
/home/judge/data/code/Main.fs(8,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

let n = stdin.ReadLine () |> int


let mutable scoreMap = Map.empty

for _ in 0..n-1 do
    let no = stdin.ReadLine () |> int
    let [|m; s|] = stdin.ReadLine().Split " " |> Array.map int
    let tags = stdin.ReadLine().Split " "
    for i in tags do
        scoreMap <- scoreMap.Add (i, s + (if scoreMap.ContainsKey i then scoreMap.[i] else 0))
        
        
scoreMap
    |> Map.toArray
    |> Array.sortWith (fun (tag1, value1) (tag2, value2) -> if value1 = value2 then compare tag1 tag2 else -(compare value1 value2))
    |> (fun arr -> if arr.Length < 10 then arr else Array.take 10 arr)
    |> Array.iter (fun (tag, value) -> printfn "%s %d" tag value)
0