Submission #999523

#TimeUsernameProblemLanguageResultExecution timeMemory
999523SonicMLPoi (IOI09_poi)C++14
100 / 100
388 ms12200 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct Cow { int score; int solve; int id; }; bool compareCow(Cow a, Cow b) { if(a.score == b.score) { if(a.solve == b.solve) { return (a.id < b.id); } return (a.solve > b.solve); } return (a.score > b.score); } int const NMAX = 2000; int freq[1 + NMAX]; Cow arr[1 + NMAX]; bool mat[1 + NMAX][1 + NMAX]; int main() { int n, t, p; cin >> n >> t >> p; for(int i = 1;i <= n;i++) { for(int j = 1;j <= t;j++) { cin >> mat[i][j]; freq[j] += mat[i][j]; } } for(int i = 1;i <= n;i++) { arr[i].id = i; for(int j = 1;j <= t;j++) { if(mat[i][j] == 1) { arr[i].score += (n - freq[j]); arr[i].solve++; } } } sort(arr+1, arr+n+1, compareCow); for(int i = 1;i <= n;i++) { if(arr[i].id == p) { cout << arr[i].score << ' ' << i << '\n'; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...