社区讨论
30分,帮忙调一下
B3968[GESP202403 五级] 成绩排序参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @mk9qse5m
- 此快照首次捕获于
- 2026/01/11 21:00 2 个月前
- 此快照最后确认于
- 2026/01/16 09:45 2 个月前
#1 #2 #3 AC
剩下的WA
代码:
CPP#include<bits/stdc++.h>
using namespace std;
int n,b[10010];
struct STU{
int total;
int mat;
int eng;
int chi;
int id;
int mctotal;
int mcmax;
}a[10010];
bool cmp(STU x, STU y) {
if(x.total != y.total) return x.total > y.total;
if(x.mctotal != y.mctotal) return x.mctotal > y.mctotal;
return x.mcmax > y.mcmax;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++) {
cin >> a[i].chi >> a[i].mat >> a[i].eng;
a[i].total = a[i].chi + a[i].mat + a[i].eng;
a[i].mctotal = a[i].mat + a[i].chi;
a[i].mcmax = max(a[i].mat, a[i].chi);
a[i].id = i;
}
sort(a + 1, a + 1 + n,cmp);
int u = 1;
int j = 1;
b[a[1].id] = u;
for(int i = 2;i <= n;i++){
if(a[i].total != a[i - 1].total || a[i].mcmax != a[i - 1].mcmax || a[i].mctotal != a[i - 1].mctotal) {
b[a[i].id] = u + j;
j = 1;
u += j;
}
else {
j++;
b[a[i].id] = u;
}
}
for(int i = 1;i <= n;i++) {
cout << b[i] << endl;
}
return 0;
}
求调
回复
共 1 条回复,欢迎继续交流。
正在加载回复...