#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)cin >> l[i]; mapmp; map>k; int t; cin >> t; rep(i, t) { string s; char c; cin >> s >> c; int p = (int)c - 'A'; cnt[p]++; k[s].push_back(P(p, (int)floor(50. * (double)l[p] + (50. * (double)l[p]) / (0.8 + 0.2*(double)cnt[p])))); mp[s].first += (int)floor(50. * (double)l[p] + (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) { bool flag = false; for (auto p : k[v[i].first]) { if (p.first == j) { cout << ' ' << p.second; flag = true; break; } } if (!flag)cout << " 0"; } cout << ' ' << v[i].second.first << endl; } }