結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2018-01-09 19:01:30 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 37 ms / 2,000 ms |
| コード長 | 2,504 bytes |
| コンパイル時間 | 1,018 ms |
| コンパイル使用メモリ | 117,292 KB |
| 実行使用メモリ | 20,480 KB |
| 最終ジャッジ日時 | 2024-10-07 22:22:12 |
| 合計ジャッジ時間 | 2,494 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
using System.Text;
using System.Threading.Tasks;
namespace Contest
{
class Scanner
{
private string[] line = new string[0];
private int index = 0;
public string Next()
{
if (line.Length <= index)
{
line = Console.ReadLine().Split(' ');
index = 0;
}
var res = line[index];
index++;
return res;
}
public int NextInt()
{
//Console.WriteLine(Next());
return int.Parse(Next());
//return 1;
}
public long NextLong()
{
return long.Parse(Next());
}
public string[] Array()
{
line = Console.ReadLine().Split(' ');
index = line.Length;
return line;
}
public int[] IntArray()
{
return Array().Select(int.Parse).ToArray();
}
public long[] LongArray()
{
return Array().Select(long.Parse).ToArray();
}
}
class HashMap<K, V> : Dictionary<K, V>
{
new public V this[K i]
{
get
{
V v;
return TryGetValue(i, out v) ? v : base[i] = default(V);
}
set { base[i] = value; }
}
}
class Program
{
HashMap<string, int> Hs = new HashMap<string, int>();
public void Solve()
{
var sc = new Scanner();
var n = sc.NextInt();
for (int i = 0; i < n; i++)
{
sc.Next();
sc.Next();
var s = sc.NextInt();
var tag = sc.Array();
foreach (var ss in tag)
{
Hs[ss] += s;
}
}
var ans = Hs.ToArray();
Array.Sort(ans, (a, b) =>
{
if (a.Value == b.Value)
{
return a.Key.CompareTo(b.Key);
}
return -a.Value.CompareTo(b.Value);
});
for (int i = 0; i < Math.Min(10, ans.Length); i++)
{
var p = ans[i];
Console.WriteLine($"{p.Key} {p.Value}");
}
}
static void Main(string[] args)
{
new Program().Solve();
}
}
}
mban