社区讨论
HELP!0分求调
B3968[GESP202403 五级] 成绩排序参与者 2已保存回复 2
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 2 条
- 当前快照
- 1 份
- 快照标识符
- @mhjrme3b
- 此快照首次捕获于
- 2025/11/04 07:22 4 个月前
- 此快照最后确认于
- 2025/11/04 07:22 4 个月前
CPP
#include<bits/stdc++.h>
#define ll long long
using namespace std;
struct student
{
int chn=0;
int mah=0;
int eng=0;
int sum=0;
int num=0;
int pm=0;
}stu[200005];
bool cmp(student a,student b)
{
if(a.sum!=b.sum)
return a.sum>b.sum;
else if((a.mah+a.chn)!=(b.mah+b.chn))
return (a.mah+a.chn)>(b.mah+b.chn);
else if(max(a.mah,a.chn)!=max(b.mah,b.chn))
return max(a.mah,a.chn)>max(b.mah,b.chn);
else
return a.num<b.num;
}
main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>stu[i].chn>>stu[i].mah>>stu[i].eng;
stu[i].sum=stu[i].chn+stu[i].mah+stu[i].eng;
stu[i].num=i;
}
sort(stu+1,stu+1+n,cmp);
for(int i=1;i<=n;i++)
stu[i].pm=i;
for(int i=1;i<=n;i++)
cout<<stu[i].pm<<"\n";
return 0;
}
0pts
回复
共 2 条回复,欢迎继续交流。
正在加载回复...