#include #define ALL(v) std::begin(v),std::end(v) using lint=long long; using lubl=long double; int main(){ std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false); std::cout.setf(std::ios_base::fixed);std::cout.precision(15); lint n;std::cin>>n; std::vectorlev(n),ac(n); for(lint&x:lev)std::cin>>x; std::vectornames; std::vector>>table; lint q;std::cin>>q; while(q--){ std::string s;std::cin>>s; lint i; if(auto f=std::find(ALL(names),s);f!=names.end()){ i=f-names.begin(); }else{ i=names.size(); table.emplace_back(0,s,std::vector(n)); names.push_back(s); } char no;std::cin>>no; lint j=no-'A'; lint score=50*lev.at(j)+50*lev.at(j)/(0.8+0.2*(++ac.at(j))); std::get<2>(table.at(i)).at(j)=score; } for(auto&&row:table){ std::get<0>(row)=std::accumulate(ALL(std::get<2>(row)),0ll); } std::sort(ALL(table),std::greater<>{}); lint i=0; for(auto&&row:table){ std::cout<<++i<<" "<(row); for(auto&&x:std::get<2>(row)){ std::cout<<" "<(row)<<'\n'; } }