#include using namespace std; #define rep(i,a,b) for(int i=a;i> N; rep(i, 0, N) cin >> L[i]; cin >> T; rep(i, 0, T) cin >> Name[i] >> P[i]; map za; rep(i, 0, T) za[Name[i]] = 0; M = za.size(); int idx = 0; for (auto& p : za) za[p.first] = idx, idx++; for (auto& p : za) Dic[p.second] = p.first; rep(i, 0, T) ID[i] = za[Name[i]], Pro[i] = P[i] - 'A'; } //----------------------------------------------------------------------------------- int cnt[30]; int E[101010][30]; int lastsub[101010]; int main() { init(); rep(t, 0, T) { int id = ID[t]; int pid = Pro[t]; int rank = cnt[pid] + 1; cnt[pid]++; E[id][pid] = 50 * L[pid] + 500 * L[pid] / (8 + 2 * rank); lastsub[id] = t; } vector> v; rep(i, 0, M) { int sm = 0; rep(j, 0, N) sm += E[i][j]; v.push_back({ sm, lastsub[i] }); } sort(v.begin(), v.end(), [&](pair a, pair b) { if (a.first != b.first) return a.first > b.first; else return a.second < b.second; }); rep(i, 0, M) { int rank = i + 1; int id = ID[v[i].second]; string name = Dic[id]; printf("%d %s ", rank, name.c_str()); rep(j, 0, N) printf("%d ", E[id][j]); printf("%d\n", v[i].first); } }