#include "bits/stdc++.h" using namespace std; #define int long long #define FOR(i, a, b) for(int i=(a);i<(b);i++) #define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--) #define REP(i, n) for(int i=0; i<(n); i++) #define RREP(i, n) for(int i=(n-1); i>=0; i--) #define ALL(a) (a).begin(),(a).end() #define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end()); #define CONTAIN(a, b) find(ALL(a), (b)) != (a).end() #define array2(type, x, y) array, x> #define vector2(type) vector > #define out(...) printf(__VA_ARGS__) typedef pair pos; int pos::*x = &pos::first; int pos::*y = &pos::second; int dxy[] = {0, 1, 0, -1, 0}; /*================================*/ int N, T; signed main() { #if DEBUG std::ifstream in("input.txt"); std::cin.rdbuf(in.rdbuf()); #endif cin >> N; int L[N]; REP(i, N) cin >> L[i]; int AC[N]; vector< map > POINTS(N); REP(i, N) AC[i] = 0; map MAP; cin >> T; string name; char C; REP(i, T) { cin >> name >> C; // 50×★の数+50×★の数 / (0.8+ 0.2×ACの順位) int problem = C - 'A'; int star = L[problem]; AC[problem]++; int score = floor(50 * star + (50 * star) / (0.8 + 0.2 * AC[problem])); if (MAP.count(name) == 0) MAP[name] = *new pos(0, 0); MAP[name].first += score; MAP[name].second = i; // order POINTS[problem][name] = score; } struct User { std::string name; int score; int last; User(string _name, int _score, int _last) { name = _name; score = _score; last = _last; } }; auto comp = [](User a, User b) { return a.score < b.score || (a.score == b.score && a.last > b.last); }; priority_queue, decltype(comp)> que(comp); int rank = 1; for (auto const& item: MAP) { User *u = new User(item.first, item.second.first, item.second.second); que.push(*u); } while (!que.empty()) { User u = que.top(); que.pop(); // 順位, 名前, 各問題のスコア, スコアの合計点 cout << rank++ << " " << u.name << " "; REP(i, N) cout << POINTS[i][u.name] << " "; cout << u.score << endl; } return 0; }