/**
* @file poi.cpp
* @brief https://oj.uz/problem/view/IOI09_poi
* @version 0.1
* @date 2022-06-24
*
*
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int find_rank(const vector<int> &v, const int &target) {
int index = 0;
while(v[index] != target) index++;
return index + 1;
}
int main() {
cin.tie(nullptr);
ios_base::sync_with_stdio(false);
// DEFINE VARIABLES
int n, t, p;
cin >> n >> t >> p;
vector< vector<int> > contestants(n, vector<int>(t)); // tasks solved by each contestant
vector<int> tasks(t, 0); // worth of each task
vector<int> score(n, 0); // score of each contestant
// READ DATA
for (int i = 0; i < n; i++) {
for (int j = 0; j < t; j++) {
cin >> contestants[i][j];
// if this user solved this task
if (contestants[i][j] == 0) {
// the worth of the task decreases with each contestant that solves it
tasks[j] ++;
}
}
}
// PROCESS
//calculate score of each contestant
for (int i = 0; i < n; i++) {
for (int j = 0; j < t; j++) {
if (contestants[i][j] == 1) {
score[i] += tasks[j];
}
}
}
// get philip schore
int philip_score = score[p - 1];
// sort by score
sort(score.begin(), score.end(), greater<int>());
// as there can't be contestats with the same score
// we use philip's score to find its rank
cout << philip_score << " " << find_rank(score, philip_score) << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
10 |
Correct |
2 ms |
340 KB |
Output is correct |
11 |
Correct |
12 ms |
808 KB |
Output is correct |
12 |
Incorrect |
16 ms |
1108 KB |
Output isn't correct |
13 |
Incorrect |
36 ms |
2652 KB |
Output isn't correct |
14 |
Incorrect |
49 ms |
3668 KB |
Output isn't correct |
15 |
Incorrect |
87 ms |
6228 KB |
Output isn't correct |
16 |
Correct |
94 ms |
6612 KB |
Output is correct |
17 |
Incorrect |
184 ms |
9760 KB |
Output isn't correct |
18 |
Correct |
156 ms |
10964 KB |
Output is correct |
19 |
Correct |
224 ms |
14488 KB |
Output is correct |
20 |
Correct |
228 ms |
16052 KB |
Output is correct |