Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
45548 许云峰 奖学金 C++ Accepted 1 MS 280 KB 563 2023-03-25 16:44:35

Tests(10/10):


Code:

# include<iostream> # include<cstdio> # include<algorithm> using namespace std; struct student { int num; int Ch; int math; int Eng; int z; }; bool cmp(student a,student b){ if(a.z != b.z){ return a.z>b.z; } else if(a.Ch != b.Ch){ return a.Ch>b.Ch; } } int main() { int n; cin>>n; student a[n]; for(int i=0; i<n; i++) { cin>>a[i].Ch>>a[i].math>>a[i].Eng; a[i].num=i+1; a[i].z = a[i].Ch+a[i].math+a[i].Eng; } sort(a+0,a+n,cmp); for(int j=0;j<5;j++){ cout<<a[j].num<<' '<<a[j].z<<endl; } return 0; }