# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
348778 | Alma | Poi (IOI09_poi) | C++14 | 715 ms | 16236 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 <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
void POI (vector<vector<int>>& results, int& N, int& T, int& P) {
vector<int> value;
value.assign(T, 0);
// value of each problem
for (int i = 0; i < N; i++) {
for (int j = 0; j < T; j++) {
if (results[i][j] == 0) {
value[j]++;
}
}
}
// scores: points-solved-ID
vector<vector<int>> scores (N, vector<int> (3));
for (int i = 0; i < N; i++) {
int points = 0;
int solved = 0;
for (int j = 0; j < T; j++) {
if (results[i][j] == 1) {
points += value[j];
solved++;
}
}
scores[i][0] = points;
scores[i][1] = solved;
scores[i][2] = i+1;
}
// Philip:
int P_score = scores[P-1][0];
int P_solved = scores[P-1][1];
int P_rank;
// Philip rank
sort(scores.rbegin(), scores.rend());
for (int i = 0; i < N; i++) {
if (scores[i][0] == P_score) {
if (scores[i][1] == P_solved) {
if (scores[i][2] == P) {
P_rank = i+1;
}}}
}
cout << P_score << ' ' << P_rank << endl;
}
int main () {
int N, T, P; cin >> N >> T >> P;
vector<vector<int>> results (N, vector<int> (T));
for (int i = 0; i < N; i++) {
for (int j = 0; j < T; j++) {
int a; cin >> a;
results[i][j] = a;
}
}
POI (results, N, T, P);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |