#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)< scores; ll sum = 0; Account(){ name = "-1"; time = -1; scores.resize(N); } void AddScore(ll i, ll score){ scores[i] = score; sum += score; } string ToString(){ stringstream ss; ss << name << " "; for(ll score : scores){ ss << score << " "; } ss << sum; return ss.str(); } bool operator<(const Account &another) const { if(sum == another.sum){ return time > another.time; }else{ return sum < another.sum; } } }; ll COUNT[30]; ll calc_score(ll id, ll star){ COUNT[id]++; ll rank = COUNT[id]; return 50 * star + (50 * star) / (0.8 + 0.2 * rank); } int main(){ cin.tie(0); ios::sync_with_stdio(false); // input cin >> N; vector L(N); FOR(i, 0, N){ cin >> L.at(i); } ll T; cin >> T; map mp; FOR(i, 0, T){ string name; char P; cin >> name >> P; ll id = P - 'A'; ll star = L[id]; ll score = calc_score(id, star); // cout << name << " " << id << " " << star << " " << score << endl; mp[name].name = name; mp[name].AddScore(id, score); mp[name].time = i; } vector V; for(auto p : mp){ V.push_back(p.second); } sort(ALL(V)); reverse(ALL(V)); FOR(i, 0 ,V.size()){ cout << i+1 << " " << V[i].ToString() << endl; } return 0; }