I_AM_THREE_BODY_MAN @ 2024-05-26 10:41:12
为什么50分?!
#include<bits/stdc++.h>
using namespace std;
int n;
struct student{
int cha,mat,eng,score,id;
}a[100005];
bool cmp(student s1,student s2){
if(s1.score!=s2.score&&s1.cha!=s2.cha) return s1.score>s2.score;
else if(s1.score==s2.score&&s1.cha!=s2.cha) return s1.cha>s2.cha;
else return s1.id<s2.id;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].cha>>a[i].mat>>a[i].eng;
a[i].score=a[i].cha+a[i].mat+a[i].eng;
a[i].id=i;
}
sort(a+1,a+1+n,cmp);
for(int i=1;i<=5;i++){
if(a[i].score!=0) cout<<a[i].id<<" "<<a[i].score<<"\n";
}
return 0;
}
by NYPD @ 2024-06-16 17:10:22
真是玄学
第五个点的你的给出的答案好像是对的
by xuruizhe0711 @ 2024-07-15 17:43:49
int n;
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].china>>a[i].math>>a[i].english;
a[i].score=a[i].china+a[i].math+a[i].english;
a[i].name=i;
}
sort(a+1,a+n+1,cmp);
for(int i=1;i<=5;i++){
cout<<a[i].name<<" "<<a[i].score<<endl;
}
return 0;
}
by I_AM_THREE_BODY_MAN @ 2024-08-06 16:57:38
@xuruizhe0711 感谢