Magallan_forever @ 2018-12-15 14:24:09
sort垃圾
#include<bits/stdc++.h>
using namespace std;
struct score{
int ID,Chinese,Math,English;
};
score student[301];
bool cmp(score a,score b){
if(a.Chinese+a.Math+a.English>b.Chinese+b.Math+b.English){
return true;
}
if(a.Chinese+a.Math+a.English==b.Chinese+b.Math+b.English){
if(a.Chinese>b.Chinese){
return true;
}
if(a.Chinese==b.Chinese){
return a.ID<b.ID;
}
else{
return false;
}
}
else{
return false;
}
}
int main(){
int i0,n;
scanf("%d",&n);
for(i0=0;i0<n;i0++){
scanf("%d%d%d",&student[i0].Chinese,&student[i0].Math,&student[i0].English);
student[i0].ID=i0+1;
}
sort(student,student+4*n-1,cmp);
for(i0=0;i0<5;i0++){
printf("%d %d\n",student[i0].ID,student[i0].Chinese+student[i0].Math+student[i0].English);
}
return 0;
}
by Ophelia @ 2018-12-15 14:28:44
@qbu666666 打这么长的科目名不嫌麻烦
by Marser @ 2018-12-15 14:32:25
@qbu666666 自己数组开小就是sort的问题了是吧?
by Magallan_forever @ 2018-12-15 14:32:50
真麻烦
by Magallan_forever @ 2018-12-15 14:33:28
数据规模300,我开了301越界呵呵
by Billy●Herrington @ 2018-12-15 14:35:39
@qbu666666 301?至少要开310
by Magallan_forever @ 2018-12-15 14:35:40
@Marser 多开一个也会越界难道我手打冒泡?```
呵呵
by Magallan_forever @ 2018-12-15 14:36:14
@违规用户名BfmB*EV0 我试一下
by Billy●Herrington @ 2018-12-15 14:36:43
@qbu666666 只多开一个很容易越界的
by Magallan_forever @ 2018-12-15 14:37:56
@违规用户名BfmB*EV0 后四个还是越界了
by Magallan_forever @ 2018-12-15 14:38:14
开了310