結果

問題 No.628 Tagの勢い
コンテスト
ユーザー natoriusan
提出日時 2023-08-01 13:51:45
言語 F#
(F# 10.0)
コンパイル:
fsharp_c _filename_
実行:
/usr/bin/dotnet_wrap
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 662 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 5,515 ms
コンパイル使用メモリ 223,248 KB
実行使用メモリ 39,756 KB
最終ジャッジ日時 2026-04-27 12:03:12
合計ジャッジ時間 13,381 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.fsproj を復元しました (207 ミリ秒)。
/home/judge/data/code/Main.fs(8,9): warning FS0025: この式のパターン マッチが不完全です たとえば、値 '[|_; _; _|]' はパターンに含まれないケースを示す可能性があります。 [/home/judge/data/code/main.fsproj]
  main -> /home/judge/data/code/bin/Release/net10.0/main.dll
  main -> /home/judge/data/code/bin/Release/net10.0/publish/

ソースコード

diff #
raw source code

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