結果
問題 |
No.628 Tagの勢い
|
ユーザー |
![]() |
提出日時 | 2025-07-11 19:43:52 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 43 ms / 2,000 ms |
コード長 | 1,134 bytes |
コンパイル時間 | 4,326 ms |
コンパイル使用メモリ | 108,928 KB |
実行使用メモリ | 21,120 KB |
最終ジャッジ日時 | 2025-07-11 19:43:58 |
合計ジャッジ時間 | 6,027 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class Program { static void Main() { int n = int.Parse(Console.ReadLine()); Dictionary<string, int> dict = new Dictionary<string, int>(); for (var i = 0; i < n; ++i) { var no = Console.ReadLine(); var ms = Console.ReadLine().Trim().Split(' '); int m = int.Parse(ms[0]); int s = int.Parse(ms[1]); var tags = Console.ReadLine().Trim().Split(' '); foreach (var k in tags) { dict.TryAdd(k, 0); dict[k] += s; } } var arr = dict.Keys.Select(k => new { Key = k, Value = dict[k] }).ToArray(); Array.Sort(arr, (v0, v1) => { if (v0.Value != v1.Value) return -v0.Value.CompareTo(v1.Value); return v0.Key.CompareTo(v1.Key); }); int cnt = 0; foreach (var v in arr) { if (cnt >= 10) break; Console.WriteLine($"{v.Key} {v.Value}"); ++cnt; } } }