using System; using System.Collections.Generic; using System.Linq; public class Program { static void Main() { var Count = Splitter(Console.ReadLine()).Select(a => int.Parse(a)).First(); var Total = new Dictionary(); int Point = 0; //Total.ExAdd("a",100); for (var i = Count ;i > 0;i--){ // 読み飛ばし Console.ReadLine(); Point = Splitter(Console.ReadLine()).Select(a => int.Parse(a)).Last(); Splitter(Console.ReadLine()).ForEach(a => Total.ExAdd(a,Point)); } foreach(var xxx in Total.OrderByDescending(a => a.Value).ThenBy(b => b.Key).Take(10)){ Console.WriteLine("" + xxx.Key + " "+xxx.Value); } } static List Splitter(string Input, char Delimiter = ' '){ return new List(Input.Split(Delimiter)); } } public static class Ex { public static Dictionary ExAdd(this Dictionary ThisDic, string ThisKey, int AddValue){ if(!ThisDic.ContainsKey(ThisKey)){ ThisDic[ThisKey] = 0; } ThisDic[ThisKey] = ThisDic[ThisKey] + AddValue; return ThisDic; } }