#include using namespace std; #define FOR(i,l,r) for(int i = (l);i < (r);i++) #define ALL(x) (x).begin(),(x).end() template bool chmax(T& a,const T& b){return a < b ? (a = b,true) : false;} template bool chmin(T& a,const T& b){return b < a ? (a = b,true) : false;} typedef long long ll; int N,T; int get_score(int n,int k) { return 50.0 * n + (int) (50.0 * n / (0.8 + 0.2 * k)); } struct score{ vector problems; int sum,last; string name; bool operator>(const score& other) const{ if(this->sum != other.sum){ return this->sum > other.sum; } return this->last < other.last; } }; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); cin >> N; vector L(N); FOR(i,0,N){ cin >> L [i]; } cin >> T; map mp; vector solved(N); FOR(i,0,T){ string s; char c; cin >> s >> c; int p_idx = c - 'A'; if(mp.count(s) == 0){ mp [s].problems.assign(N,0); mp [s].name = s; } mp [s].problems [p_idx] += get_score(L [p_idx],++solved [p_idx]); mp [s].sum += get_score(L [p_idx],solved [p_idx]); mp [s].last = i; } vector standing; for(auto it : mp){ standing.push_back(it.second); } sort(ALL(standing),greater()); FOR(i,0,standing.size()){ cout << i + 1 << " " << standing [i].name << " "; FOR(j,0,N){ cout << standing [i].problems [j] << " "; } cout << standing [i].sum << endl; } return 0; }