求助
  • 板块题目总版
  • 楼主lichengxi1
  • 当前回复2
  • 已保存回复2
  • 发布时间2023/9/17 12:44
  • 上次更新2023/11/2 19:49:35
查看原帖
求助
934977
lichengxi1楼主2023/9/17 12:44

求助

https://www.luogu.com.cn/record/124972139 [ABC260B] Better Students Are Needed!

#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAXN = 1010;
struct Student{
    int Ma,En,Sc,Id;
}a[MAXN];

bool cmp(Student x,Student y){
    if(x.Ma != y.Ma) return x.Ma > y.Ma;
    if(x.En != y.En) return x.En > y.En;
    if(x.Sc != y.Sc) return x.Sc > y.Sc;
    return x.Id < y.Id;
}

signed main(){
    int n,x,y,z;cin >> n >> x >> y >> z;
    int lu = x + y + z;
    for(int i = 1;i <= n;i++){
        a[i].Id = i;
        cin >> a[i].Ma;
    }
    for(int i = 1;i <= n;i++){
        cin >> a[i].En;
        a[i].Sc = a[i].Ma + a[i].En;
    }
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    sort(a + 1,a + n + 1,cmp);
    for(int i = 1;i <= lu;i++) cout << a[i].Id << endl;
    return 0;
}
2023/9/17 12:44
加载中...