1 solutions

  • 0
    @ 2023-10-25 13:41:51
    #include <bits/stdc++.h>
    using namespace std;
    struct Person{
        int chinese;
        int math;
        int english;
        int all;
        int id;
    }G[10000];
    bool cmp(Person A,Person B){
       if(A.all==B.all){
            if(A.chinese==B.chinese){
                return A.id<B.id;
            }
            return A.chinese>B.chinese;
       }
       return A.all>B.all;
    }
    int main(){
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>G[i].chinese>>G[i].math>>G[i].english;
            G[i].id=i+1;
            G[i].all=G[i].chinese+G[i].math+G[i].english;
        }
        sort(G,G+n,cmp);
        for(int i=0;i<5;i++){
            cout<<G[i].id<<" "<<G[i].all<<endl;
        }
    
        return 0;
    }`
    

    Information

    ID
    6832
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    7
    Tags
    (None)
    # Submissions
    45
    Accepted
    12
    Uploaded By