using System; using System.Linq; using System.Text; using System.Collections.Generic; public class Program { public void Proc() { Reader.IsDebug = false; int mondaiCount = int.Parse(Reader.ReadLine()); int[] rankList = Reader.ReadLine().Split(' ').Select(a=>int.Parse(a)).ToArray(); int teisyutuCount = int.Parse(Reader.ReadLine()); Dictionary> scoreDic = new Dictionary>(); Dictionary turnDic = new Dictionary(); Dictionary juniDic = new Dictionary(); for(int i=0; i()); for(char c ='A'; c<='A' + mondaiCount-1; c++) { scoreDic[name].Add(c, 0); } } scoreDic[name][mondai] = score; } StringBuilder ans = new StringBuilder(); List>> ansList = scoreDic.ToList(); ansList.Sort((a,b)=>{ int aVal = a.Value.Sum(c=>c.Value); int bVal = b.Value.Sum(c=>c.Value); if(aVal == bVal) { return turnDic[a.Key].CompareTo(turnDic[b.Key]); } return (aVal.CompareTo(bVal)) * -1; }); int inc = 0; ansList.ForEach(a=>ans.AppendLine((++inc) + " " + a.Key + " " + string.Join(" ", a.Value.Values) + " " + a.Value.Values.Sum())); Console.Write(ans.ToString()); } public class Reader { public static bool IsDebug = true; private static System.IO.StringReader SReader; private static string InitText = @" 3 2 2 4 4 ame A yuki B yuki A ame B "; public static string ReadLine() { if(IsDebug) { if(SReader == null) { SReader = new System.IO.StringReader(InitText.Trim()); } return SReader.ReadLine(); } else { return Console.ReadLine(); } } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }