Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
45544 马昭懿 奖学金 C++ Accepted 1 MS 296 KB 556 2023-03-25 16:41:58

Tests(10/10):


Code:

#include<iostream> #include<algorithm> using namespace std; struct st{ int a; double c; double m; double e; int temp; }; bool cmp(st a,st b){ if(a.temp!=b.temp){ return a.temp>b.temp; } if(a.temp==b.temp){ return a.c>b.c; } if(a.c==b.c){ return a.a>b.a; } } int main(){ int n,p=0; st t[500]; cin>>n; for(int i=0;i<n;i++) { cin>>t[i].c>>t[i].m>>t[i].e; t[i].a=i+1; t[i].temp=t[i].c+t[i].m+t[i].e; } sort(t,t+n,cmp); for(int m=0;m<5;m++) cout<<t[m].a<<" "<<t[m].temp<<endl; return 0; }