#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define i_7 1000000007 #define i_5 1000000005 ll mod(ll a){ ll c=a%i_7; if(c>=0)return c; else return c+i_7; } typedef pair i_i; typedef pair l_l; ll inf=1000000000000;/*10^12*/ #define rep(i,l,r) for(ll i=l;i<=r;i++) ll max(ll a,ll b){if(ab)return b;else return a;} ////////////////////////////////////// #define N 30 struct person{ string name; int score[N]; int sumscore=0; ll lastsubmit=0; }; bool comp(person a,person b){ if(a.sumscore==b.sumscore&&a.lastsubmitb.sumscore){ return true; }else return false; } int ansnum[N]; int main(){ int n;cin>>n; int l[n];rep(i,0,n-1)cin>>l[i]; int t;cin>>t; vector p; memset(ansnum,0,sizeof(ansnum)); rep(i,0,t-1){ string name1;cin>>name1; string prob;cin>>prob; int q;q=prob[0]-'A'; ansnum[q]++; ll size=p.size(); int pos=0; while(pos<=size-1){ if(p[pos].name!=name1){ pos++; }else{ break; } } if(pos==size){ person newp; newp.name=name1; rep(i,0,n-1)newp.score[i]=0; p.push_back(newp); } p[pos].lastsubmit=i; p[pos].score[q]=50*l[q]+(int)((double)(50*l[q])/(double)(0.8+0.2*(double)ansnum[q])); p[pos].sumscore+=p[pos].score[q]; } sort(p.begin(),p.end(),comp); ll size=p.size(); rep(i,0,size-1){ cout<