#include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rall(x) (x).rbegin(),(x).rend() using namespace std; typedef long long ll; typedef pair pi; typedef pair pl; typedef pair pls; int L[30]; int prob_rank[30]; int num = 1; map prob; map m; mapprob_no; struct data_t{ ll score[30]; string name; int rank; ll sum = 0; bool operator<(const data_t& right)const { return sum > right.sum; } }; int main() { int n,t; cin >> n; for (int i = 0; i < n; i++) cin >> L[i]; for (int i = 0, c = 'A'; i < n; i++,c++) prob[c] = L[i]; for (int i = 1, c = 'A'; i <= n; i++, c++) prob_no[c] = i; cin >> t; vector player(t+1); for (int i = 0; i < t; i++) { string name; char c; cin >> name >> c; if (!m[name]) { m[name] = num++; } prob_rank[prob_no[c]]++; player[m[name]-1].name = name; player[m[name]-1].score[prob_no[c]] = 50 * prob[c] + 50*prob[c] / (0.8 + 0.2*prob_rank[prob_no[c]]); player[m[name]-1].sum += player[m[name]-1].score[prob_no[c]]; player[m[name] - 1].rank = i; } sort(player.begin(),player.end()); for (int i = 0; i < num - 2; i++) { for (int j = i + 1; j < num - 1; j++) { if (player[i].sum == player[j].sum) { if (player[i].rank > player[j].rank) { swap(player[i], player[j]); } } } } for (int i = 0; i < num-1; i++) { cout << i+1 << " " << player[i].name <<" "; for (int j = 1; j <= n; j++) { cout << player[i].score[j] << " "; } cout << player[i].sum << endl; } return 0; }