1 #include<stdio.h>
2 #include<stdlib.h>
3 int main()
4 {
5 typedef struct STU
6 {
7 char name[20];
8 int score1,score2,num,sum;
9 char m,w;
10 }stu;
11 int i,k,total,n,N;
12 stu s[100];
13 scanf("%d",&N);
14 while(N--)
15 {
16 scanf("%d",&n);
17 for(i=0;i<n;i++)
18 {
19 getchar();
20 scanf("%s%d%d %c %c%d",s[i].name,&s[i].score1,&s[i].score2,&s[i].m,&s[i].w,&s[i].num);
21 }
22 for(i=total=0;i<n;i++)
23 {
24 s[i].sum=0;
25 if(s[i].score1>80&&s[i].num>0)
26 s[i].sum+=8000;
27 if(s[i].score1>85&&s[i].score2>80)
28 s[i].sum+=4000;
29 if(s[i].score1>90)
30 s[i].sum+=2000;
31 if(s[i].score1>85&&s[i].w=='Y')
32 s[i].sum+=1000;
33 if(s[i].score1>80&&s[i].m=='Y')
34 s[i].sum+=850;
35 total+=s[i].sum;
36 }
37 for(i=k=0;i<n;i++)
38 if(s[k].sum<s[i].sum)
39 k=i;
40 printf("%s\n%d\n%d\n",s[k].name,s[k].sum,total);
41 }
42 //system("pause");
43 return 0;
44 }