#include #include #include #include using namespace std; struct solver{ int score = 0;//合計得点 int last;//最終更新時 string name; map m; }; int main(){ int n, t; cin >> n; pair l[n]; for(int i = 0; i < n; i++){ cin >> l[i].first; l[i].second = 1; } map solvers; cin >> t; for(int i = 0; i < t; i++){ string name; char pi; cin >> name >> pi; int p = pi - 'A', score = 50 * l[p].first + 500 * l[p].first / (8 + 2 * l[p].second++); solvers[name].score += score; solvers[name].last = i; solvers[name].name = name; solvers[name].m[p] = score; } vector s; for(auto itr = solvers.begin(); itr != solvers.end(); itr++) s.emplace_back(itr->second); sort(s.begin(), s.end(), [](const solver& a, const solver& b){return a.score == b.score ? a.last > b.last : a.score < b.score;}); reverse(s.begin(), s.end()); for(int i = 0; i < s.size(); i++){ cout << i + 1 << ' ' << s[i].name << ' '; for(int j = 0; j < n; j++) cout << s[i].m[j] << ' '; cout << s[i].score << endl; } }