using System; using System.Collections.Generic; class Problem { public char Name { get; set; } public int Level { get; set; } public int Solve { get; set; } = 0; public Problem(int level) { Level = level; } public static int GetId(char name) { return name - 'A'; } } class Submit { public string Name { get; set; } public char ProblemName { get; set; } public Submit(string name, char problemName) { Name = name; ProblemName = problemName; } } class Participant : IEquatable, IComparable { public string Name { get; set; } public List Score { get; set; } public int ScoreSum { get; set; } = 0; public int LastSubmit { get; set; } public Participant(string name) { Name = name; } public Participant(string name, int problemNum, int lastSubmit) { Name = name; Score = new List(); for (int i = 0; i < problemNum; i++) Score.Add(0); LastSubmit = lastSubmit; } bool IEquatable.Equals(Participant p) { if (p == null) return false; else return (Name == p.Name); } public int CompareTo(Participant p) { if (ScoreSum.CompareTo(p.ScoreSum) == 0) return LastSubmit.CompareTo(p.LastSubmit); else return p.ScoreSum.CompareTo(ScoreSum); } public void Solve(int no, int level, int rank) { Score[no] = 50 * level + (500 * level / (8 + 2 * rank)); ScoreSum += Score[no]; } } class Program { static void Main() { int N = int.Parse(Console.ReadLine()); var problemList = new List(N); string[] strtmp = Console.ReadLine().Split(' '); for (int i = 0; i < N; i++) problemList.Add(new Problem(int.Parse(strtmp[i]))); int T = int.Parse(Console.ReadLine()); var submitList = new List(T); var participantList = new List(); for (int i = 0; i < T; i++) { strtmp = Console.ReadLine().Split(' '); submitList.Add(new Submit(strtmp[0], char.Parse(strtmp[1]))); if (!participantList.Contains(new Participant(submitList[i].Name))) participantList.Add(new Participant(submitList[i].Name, N, i)); int tmpProblemNo = Problem.GetId(submitList[i].ProblemName); int tmpParticipantNo = participantList.IndexOf(new Participant(submitList[i].Name)); problemList[tmpProblemNo].Solve++; participantList[tmpParticipantNo].Solve( tmpProblemNo, problemList[tmpProblemNo].Level, problemList[tmpProblemNo].Solve); participantList[tmpParticipantNo].LastSubmit = i; } participantList.Sort(); for (int i = 0; i < participantList.Count; i++) { Console.Write((i + 1) + " " + participantList[i].Name + " "); for (int j = 0; j < problemList.Count; j++) Console.Write(participantList[i].Score[j] + " "); Console.WriteLine(participantList[i].ScoreSum); } } }