https://www.luogu.org/problemnew/show/P1093
随便扭扭
#include<bits/stdc++.h> using namespace std; #define ll long long int n; struct P{ int id; int ch; int ma; int en; int sum; void calc(){ sum=ch+ma+en; } bool operator<(P p){ if(sum==p.sum){ if(ch==p.ch){ return id<p.id; } else return ch>p.ch; } else return sum>p.sum; } }p[305]; int main(){ scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d%d",&p[i].ch,&p[i].ma,&p[i].en); p[i].id=i+1; p[i].calc(); } sort(p,p+n); for(int i=0;i<5;i++){ printf("%d %d\n",p[i].id,p[i].sum); } }
原文:https://www.cnblogs.com/Yinku/p/10317163.html