#include #define INF 0x3f3f3f3f #define rep(i,n)for(int i=0;iP; int l[30]; int cnt[30]; int main() { int n; scanf("%d", &n); rep(i, n)scanf("%d", &l[i]); mapmp; map>k; int t; scanf("%d", &t); rep(i, t) { string s; char p; cin >> s >> p; p -= 'A'; cnt[p]++; k[s].push_back(P(p, 50 * l[p] + (int)floor((double)50 * (double)l[p] / (0.8 + 0.2*(double)cnt[p])))); mp[s].first += 50 * l[p] + (int)floor((double)50 * (double)l[p] / (0.8 + 0.2*(double)cnt[p])); mp[s].second = i; } vector>v; for (auto p : mp)v.push_back(p); sort(v.begin(), v.end(), [](paira, pairb) { if (a.second.first != b.second.first)return a.second.first > b.second.first; return a.second.second < b.second.second; }); rep(i, v.size()) { cout << i + 1 << ' ' << v[i].first; rep(j, n) { auto itr = k[v[i].first].begin(); for (; itr != k[v[i].first].end(); itr++) { if ((*itr).first == j) { cout << ' ' << (*itr).second; goto g; } } cout << " 0"; g:; } cout <<' '<< v[i].second.first << endl; } }