#include #include #include using namespace std; struct grd { string name; int last_ac, point; int p[27]; }; int N, L[27], Lsub[27], T, g_size = 0; grd g[4002]; bool comp(const grd &g1, const grd &g2) { if(g1.point == g2.point) return g1.last_ac < g2.last_ac; return g1.point > g2.point; } int main(void) { cin.tie(0); ios::sync_with_stdio(false); fill(Lsub, Lsub + 27, 1); string n; char p; bool flag = false; cin >> N; for(int i = 0; i < N; i++) { cin >> L[i]; } cin >> T; for(int i = 0; i < T; i++) { cin >> n >> p; flag = false; for(int j = 0; j < g_size; ++j) { if(g[j].name == n) { g[j].p[p - 'A'] = 50*L[p-'A'] + (int)(50*L[p-'A'] / (0.8 + 0.2 * Lsub[p-'A']++)); g[j].point+=g[j].p[p-'A']; g[j].last_ac = i; flag = true; } } if(!flag) { g[g_size].name = n; g[g_size].p[p-'A'] = 50*L[p-'A'] + (int)(50*L[p-'A'] / (0.8 + 0.2 * Lsub[p-'A']++)); g[g_size].point+=g[g_size].p[p-'A']; g[g_size].last_ac = i; g_size++; } } sort(g, g + g_size, comp); for(int i = 0; i < g_size; ++i) { cout << i+1 << " " << g[i].name << " "; for(int j = 0; j < N; ++j) { cout << g[i].p[j] << " "; } cout << g[i].point << endl; } }