Submission #923352

#TimeUsernameProblemLanguageResultExecution timeMemory
923352ZygnoPoi (IOI09_poi)C++17
0 / 100
511 ms24408 KiB
#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> score;
vector<int> taskScore;
vector<tuple<int, int, int>> contestantScore;

int main(){
    
    int n; // Number of contestants
    int t; // Number of tasks
    int p; // Philip’s ID was P    
    
    cin >> n >> t >> p;

    //Read the task scores
    for(int i = 0; i < n; i++){ // Contestant
        score.push_back(std::vector<int>()); // Add a new row
        for(int j = 0; j < t; j++){ // Task
            int a;
            cin >> a;
            score[i].push_back(a); // Add an element to the first row
        }
    }

    //Calculate the task scores
    for(int j = 0; j < t; j++){ // Task
        int points = 0;
        for(int i = 0; i < n; i++){ // Contestant
            if(score[i][j] == 0) points++;
        }
        taskScore.push_back(points);
    }

    //Calculate the contestant scores
    for(int i = 0; i < n; i++){ // Contestant
        int points = 0;
        for(int j = 0; j < t; j++){ // Task
            if(score[i][j] == 1){
                points += taskScore[j];
            }
        }
        tuple<int, int, int> temp = make_tuple(i, points, -1);
        contestantScore.push_back(temp);
    }
    
    //Sort the contestant scores
    sort(contestantScore.begin(), contestantScore.end(), [](const tuple<int, int, int> &a, const tuple<int, int, int> &b) {
        return get<1>(a) > get<1>(b);
    });

    //Calculate the final standings
    int currentRank = 1;
    get<2>(contestantScore[0]) = currentRank;
    for(int i = 1; i < n; i++){ // Contestant
        if(get<1>(contestantScore[i]) < get<1>(contestantScore[i-1])){
            currentRank = i+1;
        }
 
        get<2>(contestantScore[i]) = currentRank;         
    }

    cout << get<1>(contestantScore[p-1]) << " " << get<2>(contestantScore[p-1]) << endl;    

    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...