結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-01 13:51:45 |
| 言語 | F# (F# 4.0) |
| 結果 |
AC
|
| 実行時間 | 362 ms / 2,000 ms |
| コード長 | 662 bytes |
| コンパイル時間 | 7,126 ms |
| コンパイル使用メモリ | 205,120 KB |
| 実行使用メモリ | 36,892 KB |
| 最終ジャッジ日時 | 2024-10-11 05:33:52 |
| 合計ジャッジ時間 | 14,982 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (243 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/
ソースコード
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)