-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1142.cpp
More file actions
49 lines (40 loc) · 921 Bytes
/
1142.cpp
File metadata and controls
49 lines (40 loc) · 921 Bytes
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
/*************************************************************************
> File Name: 1142.cpp
> Author: dulun
> Mail: [email protected]
> Created Time: 2016年02月29日 星期一 13时29分23秒
************************************************************************/
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
struct stu
{
int a, b, c, sum;
int num;
};
stu st[1008];
bool cmp(stu p, stu q)
{
if(p.sum != q.sum) return p.sum > q.sum;
if(p.a != q.a) return p.a > q.a;
return p.num < q.num;
}
int main()
{
int m, n;
cin>>m;
for(int i = 0; i < m; i++)
{
cin>> st[i].a >> st[i].b >> st[i].c;
st[i].sum = st[i].a + st[i].b + st[i].c;
st[i].num = i;
}
sort(st, st + m, cmp);
for(int i = 0; i < 5; i++)
{
cout<<st[i].num+1<<" "<<st[i].sum<<endl;
}
return 0;
}