Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
45562 | 刁泓烨 | 奖学金 | C++ | Accepted | 2 MS | 276 KB | 592 | 2023-03-25 16:55:43 |
#include<iostream> #include<algorithm> using namespace std; struct student { float id; float c; float m; float e; float tot; }; bool cmp(student a ,student b) { if(a.tot != b.tot ) { return a.tot >b.tot ; } else if(a.c != b.c ) { return a.c>b.c; } else if(a.id != b.id ){ return a.id <b.id ; } } student a[301]; int main() { int n; cin>>n; for(int i=0; i<n; i++) { cin>>a[i].c>>a[i].m>>a[i].e; a[i].id =i+1; a[i].tot =a[i].c +a[i].e +a[i].m ; } sort(a+0,a+n,cmp); for(int i=0; i<5; i++) { cout<<a[i].id <<" "<<a[i].tot <<endl; } }