# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
583130 | evening_g | Poi (IOI09_poi) | C++11 | 73 ms | 65536 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.
/**
* @file poi.cpp
* @brief https://oj.uz/problem/view/IOI09_poi
* @version 0.1
* @date 2022-06-24
*
*
*/
#include<bits/stdc++.h>
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);
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
// DEFINE VARIABLES
int n, t, p, x;
cin >> n >> t >> p;
vector< vector<int> > contestants(n, {t, 0}); // tasks solved by each contestant
vector<int> tasks(t, n); // 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] == 1) {
// 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) {
// the worth of the task decreases with each contestant that solves it
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;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |