#include<bits/stdc++.h>
using namespace std;
struct stu
{
string name;
int c;
int m;
int e;
int a;
int rank;
char ch;
}p[10010];
int top,cnt;
map<string,int> mp;
bool cpa(stu x,stu y)
{
if(x.a!=y.a)
return x.a>y.a;
}
bool cpc(stu x,stu y)
{
if(x.c!=y.c)
return x.c>y.c;
}
bool cpm(stu x,stu y)
{
if(x.m!=y.m)
return x.m>y.m;
}
bool cpe(stu x,stu y)
{
if(x.e!=y.e)
return x.e>y.e;
}
int main()
{
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
cin>>p[i].name>>p[i].c>>p[i].m>>p[i].e;
p[i].a=(p[i].c+p[i].m+p[i].e)/3+0.5;
}
sort(p+1,p+n+1,cpa);
top=0,cnt=0;
for(int i=1;i<=n;i++)
{
if(p[i].a!=top)
{
top=p[i].a;
cnt=i;
}
p[i].rank=cnt;
p[i].ch='A';
}
sort(p+1,p+n+1,cpc);
top=0,cnt=0;
for(int i=1;i<=n;i++)
{
if(p[i].c!=top)
{
top=p[i].c;
cnt=i;
}
if(p[i].rank>cnt)
{
p[i].rank=cnt;
p[i].ch='C';
}
}
sort(p+1,p+n+1,cpm);
top=0,cnt=0;
for(int i=1;i<=n;i++)
{
if(p[i].m!=top)
{
cnt=i;
top=p[i].m;
}
if(p[i].rank>cnt)
{
p[i].rank=cnt;
p[i].ch='M';
}
}
sort(p+1,p+n+1,cpe);
top=0,cnt=0;
for(int i=1;i<=n;i++)
{
if(p[i].e!=top)
{
top=p[i].e;
cnt=i;
}
if(p[i].rank>cnt)
{
p[i].rank=cnt;
p[i].ch='E';
}
}
for(int i=1;i<=n;i++)
mp[p[i].name]=i;
for(int i=1;i<=m;i++)
{
string s;
cin>>s;
if(mp[s])
cout<<p[mp[s]].rank<<' '<<p[mp[s]].ch<<endl;
else
cout<<"N/A"<<endl;
}
}

- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
- 100
- 101
- 102
- 103
- 104
- 105
- 106
- 107
- 108
- 109
- 110
- 111
- 112
- 113
- 114
- 115
- 116
- 117
- 118