-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjiangxuejin.cpp
45 lines (45 loc) · 874 Bytes
/
jiangxuejin.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
#include <iostream>
#include <algorithm>
using namespace std;
struct stu{
int sum;
int c,m,e;
int num;
}student[301];
bool cmp(stu a,stu b){
if(a.sum>b.sum){
return 1;
}
else if(a.sum==b.sum){
if(a.c>b.c){
return 1;
}
else if(a.c==b.c){
if(a.num>b.num){
return 0;
}
else{
return 1;
}
}
else{
return 0;
}
}
else{
return 0;
}
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
student[i].num=i;
cin>>student[i].c>>student[i].m>>student[i].e;
student[i].sum=student[i].c+student[i].m+student[i].e;
}
sort(student+1,student+1+n,cmp);
for(int i=1;i<=5;i++)
cout<<student[i].num<<' '<<student[i].sum<<endl;
return 0;
}