点个赞吧
2025-08-27 21:38:27
发布于:江苏
2阅读
0回复
0点赞
using namespace std;
struct player {
    char s[25];
    int a, b, c, sum = 0, id;
    bool operator < (player &opponent) {
        if (sum != opponent.sum) return sum > opponent.sum;
        if (a != opponent.a) return a > opponent.a;
        if (b != opponent.b) return b > opponent.b;
        return id < opponent.id;
    }
    friend istream& operator >> (istream& in, player& P) {
        in >> P.s >> P.a >> P.b >> P.c;
        P.sum = P.a + P.b + P.c;
        return in;
    }
} p[100005];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> p[i];
        p[i].id = i;
    }
    sort(p + 1, p + n + 1);
    for(int i = 1; i <= n; i++) printf("%s %d\n",p[i].s, p[i].sum);
    return 0;
}
这里空空如也







有帮助,赞一个