1 solutions

  • 0
    @ 2022-3-31 16:53:47
    #include <bits/stdc++.h>
    using namespace std;
    struct Winner{
        int num;
        double aver;
        friend bool operator<(Winner a,Winner b){
            return a.aver < b.aver;
        }
    };
    priority_queue<Winner> p;
    
    int main(){
        int n,score,sum = 0;
        cin>>n;
        Winner usr[n];
        for(int i = 0 ; i < n ; i++){
            vector<int> v;
            sum = 0;
            cin>>usr[i].num;
            for(int j = 0 ; j < 5 ; j++){
                cin>>score;
                v.push_back(score);
            }
            sort(v.begin(),v.end());
            for(int j = 1 ; j < 4 ; j++){
                sum += v[j];
            }
            usr[i].aver = sum / 3.0;
            p.push(usr[i]);
        }
        for(int i = 0 ; i < 3 ; i++){
            printf("%d %.3lf\n",p.top().num,p.top().aver);
            p.pop();
        }
        return 0;
    }
    

    Information

    ID
    652
    Time
    1000ms
    Memory
    16MiB
    Difficulty
    7
    Tags
    # Submissions
    16
    Accepted
    10
    Uploaded By