#include using namespace std; int n; struct Status { string name; int last; int sum; vector score; Status() : name(""), last(100000), sum(0) {score = vector(n, 0);} //Status(string name, int last) : name(name), last(last), sum(0) {score = vector(n, 0);} bool operator<(const Status& s) const { if (sum != s.sum) return sum > s.sum; return last < s.last; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n; vector l(n); for (int i = 0; i < n; i++) cin >> l[i]; int T; cin >> T; map mp; vector rank(n, 0); for (int i = 0; i < T; i++) { string name; char p; cin >> name >> p; if (mp.find(name) == mp.end()) mp[name].name = name; mp[name].last = i; rank[p - 'A']++; int score = 50 * l[p - 'A'] + (int)(50 * l[p - 'A'] / (0.8 + 0.2 * rank[p - 'A'])); mp[name].score[p - 'A'] = score; mp[name].sum += score; } vector result; for (pair p : mp) result.emplace_back(p.second); sort(result.begin(), result.end()); for (int i = 0; i < (int)result.size(); i++) { cout << i + 1 << " "; cout << result[i].name << " "; for (int j = 0; j < n; j++) cout << result[i].score[j] << " "; cout << result[i].sum << endl; } return 0; }