# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
923542 | Zygno | Poi (IOI09_poi) | C++17 | 221 ms | 16572 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct contestant {
int id;
int score;
int solvedTasks;
int finalRank;
contestant(int _id, int _score, int _solvedTasks, int _finalRank) {
id = _id;
score = _score;
solvedTasks = _solvedTasks;
finalRank = _finalRank;
}
contestant() {
id = -1;
score = -1;
solvedTasks = -1;
finalRank = -1;
}
};
vector<vector<int>> scoreInput;
vector<int> taskScore;
vector<contestant> contestantScore;
bool customCompare(contestant a, contestant b) {
if(a.score > b.score) return true;
if(a.score < b.score) return false;
if(a.solvedTasks > b.solvedTasks) return true;
if(a.solvedTasks < b.solvedTasks) return false;
return a.id < b.id;
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
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
scoreInput.push_back(std::vector<int>()); // Add a new row
for(int j = 0; j < t; j++){ // Task
int a;
cin >> a;
scoreInput[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(scoreInput[i][j] == 0) points++;
}
taskScore.push_back(points);
}
//Calculate the contestant scores
for(int i = 0; i < n; i++){ // Contestant
int points = 0;
int solvedTasks = 0;
for(int j = 0; j < t; j++){ // Task
if(scoreInput[i][j] == 1){
points += taskScore[j];
solvedTasks++;
}
}
contestant temp = contestant(i+1, points, solvedTasks, -1);
contestantScore.push_back(temp);
}
//Sort the contestant scores
sort(contestantScore.begin(), contestantScore.end(), customCompare);
for(int i = 0; i < n; i++){
contestantScore[i].finalRank = i+1;
}
//Sort the contestant scores by id
sort(contestantScore.begin(), contestantScore.end(), [](contestant a, contestant b) {
return a.id < b.id;
});
cout << contestantScore[p-1].score << " " << contestantScore[p-1].finalRank << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |