Submission #467268

#TimeUsernameProblemLanguageResultExecution timeMemory
467268BlancaHMPoi (IOI09_poi)C++14
100 / 100
781 ms23828 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; vector<int> points, solutionsPerProblem, problemsSolved; bool comp(int i, int j) { // comparator to sort players according to the rules if (points[i] > points[j]) return true; else if (points[i] < points[j]) return false; else if (problemsSolved[i] > problemsSolved[j]) return true; else if (problemsSolved[i] < problemsSolved[j]) return false; return i < j; } void sortPlayers(vector<vector<int>> & table, vector<int> & players) { int T = (int) table[0].size(), N = (int) players.size(); for (int i = 0; i < T; i++) { for (int j = 0; j < N; j++) solutionsPerProblem[i] += table[j][i]; } for (int i = 0; i < N; i++) { for (int j = 0; j < T; j++) { if (table[i][j]) { points[i] += (N-solutionsPerProblem[j]); problemsSolved[i]++; } } } sort(players.begin(), players.end(), comp); } int main() { int N, T, P; cin >> N >> T >> P; vector<vector<int>> table(N, vector<int>(T)); vector<int> players(N); points.assign(N, 0); problemsSolved.assign(N, 0); solutionsPerProblem.assign(T, 0); for (int i = 0; i < N; i++) { players[i] = i; for (int j = 0; j < T; j++) { cin >> table[i][j]; } } sortPlayers(table, players); for (int i = 0; i < N; i++) { if (players[i] == P-1) { cout << points[P-1] << " " << i+1 << "\n"; break; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...