#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const double pi=4*atan(1.0); constexpr long long mod=static_cast(1e9+7); using cWeightEdges=vector>>; using cEdges=vector>; struct Score{ long long score; int last_ans; vector scores; Score(int last,int N):last_ans(last),score(0),scores(N,0){} }; int get_score(int star,int order){ return 50*star+(double)((50.*(double)(star))/(0.8+0.2*(double)(order))); } int main(){ // ifstream fin("gen_case_1.txt"); int N; cin>>N; vector L(N); for(auto& val:L) cin>>val; int T; cin>>T; vector> List(T); unordered_map LastAns; for(int i=0;i>List[i].first>>str; List[i].second=str-'A'; auto itr=LastAns.find(List[i].first); if(itr!=end(LastAns)){ itr->second.last_ans=i; } else{ LastAns.insert(make_pair(List[i].first,Score(i,N))); } } vector Num(N,0); for(const auto& answer:List){ auto itr=LastAns.find(answer.first); itr->second.score+=get_score(L[answer.second],++Num[answer.second]); itr->second.scores[answer.second]=get_score(L[answer.second],Num[answer.second]); } vector> Scores(LastAns.size()); auto itr=LastAns.begin(); for(int i=0;ifirst; Scores[i].second=itr->second.score; ++itr; } sort(begin(Scores),end(Scores),[&](auto x,auto y){ if(x.second==y.second){ auto x_itr=LastAns.find(x.first); auto y_itr=LastAns.find(y.first); return x_itr->second.last_anssecond.last_ans; } else{ return x.second>y.second; } }); //ofstream fout("out.txt"); for(int i=0;isecond.scores){ cout<<" "<