初学???

P1093 [NOIP2007 普及组] 奖学金

weiyi8910 @ 2024-10-04 15:07:37

#include <bits/stdc++.h>
using namespace std;
const long long N = 10e4 + 5;

struct www {
    string name;
    int zf;
    int a;
    int b;
    int c;
    long long id;
} a[N];

bool cmp(www x, www y) {
    if (x.zf != y.zf)
        return x.zf > y.zf;
    if (x.a != y.a)
        return x.a > y.a;

    return x.id < x.id;
}

int main() {
    long long n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].a >> a[i].b >> a[i].c;
        a[i].id = i;
        a[i].zf = a[i].a + a[i].b + a[i].c;
    }
    sort(a + 1, a + n + 1, cmp);
    for (int i = 1; i <= 5; i++) {
        cout << a[i].id << " " << a[i].zf << "\n";
    }
    return 0;
}

by jingliang_youxi @ 2024-10-04 15:09:44

id


by _mei_tou_nao_ @ 2024-10-04 15:10:01

楼主开的小号,他过了


|