using System; using System.Collections.Generic; using System.Linq; namespace y { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] l = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); int[] la = new int[n]; int t = int.Parse(Console.ReadLine()); var li = new List(); int nt = 0; for (int i = 0; i < t; i++) { string[] ss = Console.ReadLine().Split(); int e = Convert.ToChar(ss[1]) - 'A'; la[e]++; int point = (int)(50 * l[e] + (50 * l[e] / (0.8 + 0.2 * la[e]))); if (li.Count(x => x.name == ss[0]) == 0) { int[] k = new int[n]; k[e] = point; var p = new Person(ss[0], k, nt); li.Add(p); } else { var u = li.Where(x => x.name == ss[0]); foreach (var item in u) { item.point[e] = point; item.lastTime = nt; } } nt++; } var ans = li.OrderByDescending(x => x.point.Sum()).ThenBy(x => x.lastTime); int h = 1; foreach (var item in ans) { string s = ""; for (int i = 0; i < n; i++) { s += item.point[i]; if (i != n - 1) s += " "; } s = h.ToString() + " " + item.name + " " + s + " " + item.point.Sum(); Console.WriteLine(s); h++; } } } public class Person { public Person(string n, int[] p, int t) { name = n; point = p; lastTime = t; } public string name = ""; public int[] point; public int lastTime = 0; } }