奖学金题解
2024-10-05 10:48:35
发布于:北京
1阅读
0回复
0点赞
#include <bits/stdc++.h>
using namespace std;
struct node{
int y,s,yin,id,sum;
}a[301];
bool cmp(node x,node y){
if(x.sum != y.sum) return x.sum > y.sum;
else if(x.sum == y.sum && x.y != y.y) return x.y > y.y;
else if(x.y == y.y) return x.id < y.id;
}
int main(){
int n;
cin >> n;
for(int i = 0;i < n;i ++){
cin >> a[i].y >> a[i].s >> a[i].yin;
a[i].sum = a[i].y + a[i].s + a[i].yin;
a[i].id = i + 1;
}
sort(a,a + n,cmp);
for(int i = 0;i < 5;i ++) cout << a[i].id << " " << a[i].sum << endl;
return 0;
}
这里空空如也
有帮助,赞一个