-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1012.cpp
89 lines (82 loc) · 1.94 KB
/
1012.cpp
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
#include<stdio.h>
#include<string.h>
#include<vector>
#include<algorithm>
using namespace std;
class Student
{
public:
char name[10];
int a,c,m,e;
};
int main()
{
int n,m,i,j,score;
char search[10];
int rank,t_rank;
char rank_ch;
vector<Student> v;
//freopen("input.in","r",stdin);
//freopen("output.out","w",stdout);
scanf("%d%d",&n,&m);
for(i=0;i<n;i++)
{
Student s;
scanf("%s%d%d%d",s.name,&s.c,&s.m,&s.e);
s.a=s.c+s.m+s.e;
v.push_back(s);
}
for(i=0;i<m;i++)
{
scanf("%s",search);
vector<Student>::iterator it;
for(it=v.begin();it!=v.end();it++)
if(strcmp(it->name,search)==0)
break;
if(it==v.end())
{
printf("N/A\n");
}
else
{
rank=1;
score=it->a;
for(j=0;j<n;j++)
if(v[j].a > score)
rank++;
rank_ch='A';
t_rank=1;
score=it->c;
for(j=0;j<n;j++)
if(v[j].c > score)
t_rank++;
if(t_rank<rank)
{
rank=t_rank;
rank_ch='C';
}
t_rank=1;
score=it->m;
for(j=0;j<n;j++)
if(v[j].m > score)
t_rank++;
if(t_rank<rank)
{
rank=t_rank;
rank_ch='M';
}
t_rank=1;
score=it->e;
for(j=0;j<n;j++)
if(v[j].e > score)
t_rank++;
if(t_rank<rank)
{
rank=t_rank;
rank_ch='E';
}
printf("%d %c\n",rank,rank_ch);
}
}
return 0;
}