Submission #564810

#TimeUsernameProblemLanguageResultExecution timeMemory
564810PiokemonPoi (IOI09_poi)C++17
100 / 100
224 ms16724 KiB
#include <bits/stdc++.h>
using namespace std;

int worth[2090];
int contestants[2090][2090];
pair<pair<int,int>,int> scores[2090];

bool comp(pair<pair<int,int>,int> a, pair<pair<int,int>,int> b){
    if (a.first.first > b.first.first){
        return 1;
    }
    else if (a.first.first < b.first.first){
        return 0;
    }
    if (a.first.second > b.first.second){
        return 1;
    }
    else if(a.first.second < b.first.second){
        return 0;
    }
    if (a.second < b.second){
        return 1;
    }
    else{
        return 0;
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n,t,p;
    cin >> n >> t >> p;
    for (int x=0;x<=t;x++){
        worth[x] = n;
    }
    for (int x=0;x<n;x++){
        for (int y=0;y<t;y++){
            cin >> contestants[x][y];
            if (contestants[x][y] == 1){
                worth[y] -= 1;
            }
        }
    }
    for (int x=0;x<n;x++){
        scores[x].first.first = 0;
        scores[x].first.second = 0;
        scores[x].second = x+1;
        for (int y=0;y<t;y++){
            if (contestants[x][y] == 1){
                scores[x].first.first += worth[y];
                scores[x].first.second += 1;
            }
        }
    }
    sort(scores,scores+n,comp);
    for (int x=0;x<n;x++){
        if (scores[x].second == p){
            cout << scores[x].first.first << ' ' << x+1 << "\n";
            return 0;
        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...