#include using namespace std; int f(int N, int K) { return (50 * N + (50 * N) / (0.8 + 0.2 * K)); } int main() { int N, L[26], T, rank[26] = {}; cin >> N; for(int i = 0; i < N; i++) { cin >> L[i]; } cin >> T; map< string, map< int, int > > ranker; map< string, int > last; map< string, int > sum; for(int i = 0; i < T; i++) { string S; char P; cin >> S >> P; P -= 'A'; ranker[S][P] = f(L[P], ++rank[P]); last[S] = i; sum[S] += ranker[S][P]; } vector< pair< pair< int, int >, string > > name; for(auto &c: sum) name.push_back({{c.second, -last[c.first]}, c.first}); sort(begin(name), end(name)); reverse(begin(name), end(name)); for(int i = 0; i < name.size(); i++) { auto &obj = name[i]; cout << i + 1 << " " << obj.second; for(int j = 0; j < N; j++) cout << " " << ranker[obj.second][j]; cout << " " << obj.first.first << endl; } }