Submission #751426

#TimeUsernameProblemLanguageResultExecution timeMemory
751426vjudge1Poi (IOI09_poi)C++17
100 / 100
245 ms23756 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define fi first #define se second bool cmp(pair <pair <ll, ll>, ll> a, pair <pair <ll, ll>, ll> b){ if(a.fi.fi == b.fi.fi){ if(a.fi.se == b.fi.se) return a.se < b.se; else return a.fi.se > b.fi.se; } else return a.fi.fi > b.fi.fi; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, m, p; cin >> n >> m >> p; p--; // 0-th based // pair {score, task solve, id} int arr[n][m]; for(int a = 0; a < n; ++a){ for(int b = 0; b < m; ++b){ cin >> arr[a][b]; } } // calculate task score ll score[m]; memset(score, 0, sizeof score); for(int a = 0; a < n; ++a){ for(int b = 0; b < m; ++b){ if(!arr[a][b]) score[b]++; } } pair <pair <ll, ll>, ll> contestants[n]; for(int a = 0; a < n; ++a){ contestants[a].se = a; contestants[a].fi.fi = 0; contestants[a].fi.se = 0; for(int b = 0; b < m; ++b){ if(arr[a][b]){ contestants[a].fi.fi += score[b]; contestants[a].fi.se++; } } } sort(contestants, contestants + n, cmp); for(int a = 0; a < n; ++a){ if(contestants[a].se == p){ cout << contestants[a].fi.fi << " " << a + 1 << '\n'; break; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...