70分求助

P1093 [NOIP2007 普及组] 奖学金

fkcufk @ 2023-07-20 12:47:02

提示:不要管我做了什么题,不要看我的做题记录。

#include <bits/stdc++.h>
#define FastIO ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
typedef long long ll;
typedef size_t ull;
const int inf = 0x3f3f3f3f;
const int homo = 114514;
using namespace std;

int n;
struct Node{
    int chi, mth, eng, id, sum;
}a[305];

void init(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a[i].chi >> a[i].mth >> a[i].eng;
        a[i].id = i;
        a[i].sum = a[i].chi + a[i].mth + a[i].eng;
    }
}

bool cmp(Node x, Node y){
    if(x.sum != y.sum) return x.sum > y.sum;
    if(x.chi != y.chi) return x.id < y.id;
    return x.chi < y.chi;
}

void work(){
    sort(a + 1, a + n + 1, cmp);
}
void ouit(){
    for(int i = 1; i <= 5; i++){
        cout << a[i].id << " " << a[i].sum << endl;
    }
}
signed main(){
    init();
    work();
    ouit();
    return 0;
}

by SunTZ @ 2023-07-20 12:47:44

此地无银三百两了,这不得赶紧开个完隐


by jhdrgfj @ 2023-07-20 12:49:36

大佬不是会动态点分治和高速平衡树吗


by EL1ka @ 2023-07-20 12:50:26

6purple2black


by fkcufk @ 2023-07-20 12:51:30

@H20CaO 我前天刚关掉完隐的我现在怎么开,而且你们不要管我那到黑题


by fkcufk @ 2023-07-20 12:51:41

@jhdrgfj 我不会


by jhdrgfj @ 2023-07-20 12:53:26

@LeapFrog233 那你是用 rand() 过的紫荆花吗


by An_Aholic @ 2023-07-20 12:54:18

@LeapFrog233 你的 cmp 写了个什么?


by An_Aholic @ 2023-07-20 12:56:02

@LeapFrog233

bool cmp(Node x, Node y){
    if(x.sum != y.sum) return x.sum > y.sum;
    if(x.chi != y.chi) return x.chi > y.chi;
    return x.id < y.id;
}

by fkcufk @ 2023-07-20 12:57:23

@SKB_Konnyaku 稍等,我改下。


by fkcufk @ 2023-07-20 13:04:29

@SKB_Konnyaku AC了,thx


|