제출 #597623

#제출 시각아이디문제언어결과실행 시간메모리
597623l_rehoPoi (IOI09_poi)C++14
100 / 100
565 ms16016 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int N, K, P; vector<vector<int>> V; vector<int> S; bool compare(array<int, 3> a1, array<int, 3> a2){ if(a1[0] > a2[0]) return true; if(a1[0] == a2[0] && a1[1] > a2[1]) return true; if(a1[0] == a2[0] && a1[1] == a2[1] && a1[2] < a2[2]) return true; return false; } void solve(){ cin>>N>>K>>P; V.assign(N, vector<int>(K, 0)); S.assign(K, 0); for(int i = 0; i < N; i++) for(int j = 0; j < K; j++) cin>>V[i][j]; for(int i = 0; i < K; i++){ for(int j = 0; j < N; j++){ S[i]+=V[j][i]; } S[i] = N-S[i]; } vector<array<int, 3>> A(N); // faccio cose for(int i = 0; i < N; i++){ int points = 0, solved = 0; for(int j = 0; j < K; j++){ solved += V[i][j]; if(V[i][j]) points += S[j]; } A[i] = array<int,3>{points, solved, i}; } sort(A.begin(), A.end(), compare); for(int i = 0; i < N; i++) if(A[i][2] == P-1){cout<<A[i][0]<<" "<<i+1<<endl; break;} } int main(){ solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...