Submission #931384

#TimeUsernameProblemLanguageResultExecution timeMemory
931384thisisadarshPoi (IOI09_poi)C++14
0 / 100
500 ms16152 KiB
#include <bits/stdc++.h> using namespace std; bool comparePairs(const pair<int, int> &a, const pair<int, int> &b) { return a.first < b.first; } bool sortBySecond(const pair<int, int> &a, const pair<int, int> &b) { return a.second < b.second; } int main(){ int N, T, P; cin >> N >> T >> P; vector<vector<int>> a(N, vector<int> (T,0)); vector<int>score(T,0); for(int i = 0; i < N; i++){ for(int j = 0; j < T; j++){ cin >> a[i][j]; } } for(int i = 0; i < T; i++){ for(int j = 0; j < N; j++){ if(a[j][i] == 0){ score[i]++; } } } vector<pair<int, int>>player_score(N); for(int i = 0; i < N; i++){ player_score[i].second = i+1; } for(int i = 0; i < N; i++){ for(int j = 0; j < T; j++){ if(a[i][j] != 0){ player_score[i].first += score[j]; } } } sort(player_score.begin(), player_score.end(), comparePairs); bool ok = false; int pos = -1, s = 0; for(int i = 0; i < N; i++){ if(player_score[i].second == P){ if(i+1 < N && player_score[i+1].first == player_score[i].first){ ok = true; } if(i-1 >= 0 && player_score[i-1].first == player_score[i].first){ ok = true; } else{ pos = i+1; s = player_score[i].first; } } } if(ok == false){ cout << s << ' ' << pos << '\n'; return 0; } sort(player_score.begin(), player_score.end(), sortBySecond); for(int i = 0; i < N; i++){ if(player_score[i].second == P){ pos = i+1; s = player_score[i].first; } } cout << s << ' ' << pos << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...