#include using namespace std; using ll = long long; using PII = std::pair; using PLL = std::pair; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rep2(i, s, n) for (int i = (s); i < (int)(n); i++) struct player { string name; int time; int total; vector points; }; int getpoint(int star, int order) { return 50 * star + 500 * star / (8 + 2 * order); } int main() { #ifdef DEBUG cout << "DEBUG MODE" << endl; ifstream in("input.txt"); //for debug cin.rdbuf(in.rdbuf()); //for debug #endif int n, t, c, p; c = 1; string name; char probrem; vector init_point; vector players; map player_name; cin >> n; int star[n], order[n]; fill(order, order + n, 0); rep(i, n) { cin >> star[i]; init_point.push_back(0); } cin >> t; rep(i, t) { cin >> name >> probrem; if (player_name[name] == 0) { players.push_back((player){name, i, 0, init_point}); player_name[name] = c; c++; } order[probrem - 'A']++; p = getpoint(star[probrem - 'A'], order[probrem - 'A']); players[player_name[name] - 1].points[probrem - 'A'] = p; players[player_name[name] - 1].total += p; players[player_name[name] - 1].time = i; } sort(players.begin(), players.end(), [](const player &a, const player &b){ if (a.total > b.total) return a.total > b.total; else return a.time < b.time; }); c = 1; for (auto z : players) { cout << c << " " << z.name << " "; for (auto y : z.points) cout << y << " "; cout << z.total << endl; c++; } return 0; }