#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; int N; int levels[30], s_cnt[30]; map _m; map > _m2; int score(int pid){ return 50 * levels[pid] + 500 * levels[pid] / (8 + 2 * ++s_cnt[pid]); } int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); std::cin >> N; for(int i=0;i> levels[i]; } int T; std::cin >> T; for(int i=0;i> name >> problem; int pid = problem - 'A'; int sc = score(pid); int s; tie(s, ignore) = _m[name]; _m[name] = std::make_tuple(s + sc, i); _m2[name].emplace_back(pid, sc); } vector > v; for(const auto &p : _m){ v.emplace_back(-fst(p.second), snd(p.second), p.first); } sort(v.begin(), v.end()); int M = v.size(); for(int i=0;i