結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-06-21 03:02:15 |
| 言語 | OCaml (5.2.1) |
| 結果 |
AC
|
| 実行時間 | 8 ms / 2,000 ms |
| コード長 | 916 bytes |
| コンパイル時間 | 407 ms |
| コンパイル使用メモリ | 21,576 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2024-10-09 01:33:47 |
| 合計ジャッジ時間 | 1,349 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 19 |
ソースコード
Scanf.scanf "%d" (fun n ->
let module M = Map.Make (struct type t = string let compare = compare end) in
let rec loop i acc =
if i = n then acc else
let acc = Scanf.scanf " %d %d %d" (fun no m s ->
let rec loop_j j acc =
if j = m then acc else
let acc = Scanf.scanf " %s" (fun key ->
M.add key (s + try M.find key acc with _ -> 0) acc)
in
loop_j (j + 1) acc
in
loop_j 0 acc
)
in
loop (i + 1) acc
in
let map = loop 0 M.empty in
let a = Array.of_list @@ M.bindings map in
Array.sort (fun (a1, b1) (a2, b2) -> compare (-b1, a1) (-b2, a2)) a;
for i = 0 to min 9 (Array.length a - 1) do
let (tag, sc) = a.(i) in
Printf.printf "%s %d\n" tag sc
done
)