# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
923352 | Zygno | Poi (IOI09_poi) | C++17 | 511 ms | 24408 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |