#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int rec[1000000][4], flag;
char ch[4] = {'A', 'C', 'M', 'E'};
struct node{
int id, score[4];
}stu[2010];
bool cmp(node a, node b){
return a.score[flag] > b.score[flag];
}
int main(){
int N, M;
cin >> N >> M;
for(int i = 0; i < N; i++){
cin >> stu[i].id >> stu[i].score[1] >> stu[i].score[2] >> stu[i].score[3];
stu[i].score[0] = round(1.0 * (stu[i].score[1] + stu[i].score[2] + stu[i].score[3]) / 3);
}
for(flag = 0; flag < 4; flag++){
sort(stu, stu + N, cmp);
for(int j = 0; j < N; j++){
if(j != 0 && stu[j].score[flag] == stu[j-1].score[flag])
rec[stu[j].id][flag] = rec[stu[j-1].id][flag];
else rec[stu[j].id][flag] = j + 1;
}
}
int qid, mi;
for(int k = 0; k < M; k++){
cin >> qid;
if(rec[qid][0] == 0) cout << "N/A\n";
else{
int min = N, pos;
for(int i = 0; i < 4; i++){
if(rec[qid][i] < min){
min = rec[qid][i]; pos = i;
}
}
printf("%d %c\n", min, ch[pos]);
}
}
return 0;
}
1012 The Best Rank
最新推荐文章于 2022-02-20 18:49:14 发布