2 条题解
-
0
Infinity_ LV 8 @ 2024-09-01 13:13:18
#include<stdio.h> #include<algorithm> using namespace std; struct stu{ int sum, Chinese, num; }a[305]; bool cmp(stu x, stu y){ if(x.sum != y.sum)return x.sum > y.sum; if(x.Chinese != y.Chinese)return x.Chinese > y.Chinese; return x.num < y.num; } int main(){ int n, p, q; scanf("%d", &n); for(int i = 1; i <= n; i++){ scanf("%d%d%d", &a[i].Chinese, &p, &q); a[i].sum = a[i].Chinese + p + q; a[i].num = i; } sort(a+1, a+n+1, cmp); for(int i = 1; i <= 5; i++)printf("%d %d\n", a[i].num, a[i].sum); return 0; }
-
02022-03-11 13:22:11@
#include <bits/stdc++.h> using namespace std; int main() { long long i,ans[20000],x,y,z,n; cin>>n; for (i=1;i<=n;i++) { cin>>x>>y>>z; ans[i]=(x+y+z)*100000000+x*100000+99999-i; } sort(ans+1,ans+n+1); for (i=n;i>n-5;i--) cout<<99999-ans[i]%100000<<" "<<ans[i]/100000000<<endl; return 0; }
- 1