#include "bits/stdc++.h" using namespace std; #define DEBUG(x) cout<<#x<<": "< #define vl vector #define vii vector< vector > #define vll vector< vector > #define vs vector #define pii pair #define pis pair #define psi pair const int inf = 1000000001; const ll INF = 1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 #define Sp(p) cout<> n; vi l(n); for (i = 0; i < n; i++) { cin >> l[i]; } int t; cin >> t; vii solved(n, vi()); map name2ind; int cnt = 0; vector > person; for (i = 0; i < t; i++) { string name; char p; cin >> name >> p; int ind; if (name2ind[name] == 0) { name2ind[name] = ++cnt; person.push_back(make_pair(pii(0, 0), pis(cnt - 1, name))); } ind = name2ind[name] - 1; solved[p - 'A'].push_back(ind); person[ind].first.second = (inf - i); } vii hyou(cnt, vi(n)); for (i = 0; i < n; i++) { for (j = 0; j < solved[i].size(); j++) { hyou[solved[i][j]][i] = 50 * l[i] + 50*l[i] / (0.8 + 0.2 * (j + 1)); person[solved[i][j]].first.first += hyou[solved[i][j]][i]; } } sort(person.begin(), person.end()); reverse(person.begin(), person.end()); for (i = 0; i < cnt; i++) { cout << i + 1 << " " << person[i].second.second << " "; int ind = person[i].second.first; for (j = 0; j < n; j++) { cout << hyou[ind][j] << " "; } cout << person[i].first.first << endl; } } /* 2 1 2 3 ame A yuki B yuki A 3 2 2 4 4 ame A yuki B yuki A ame B 8 6 5 4 3 2 1 1 1 3 rian F rian G rian H */