Submission #924796

#TimeUsernameProblemLanguageResultExecution timeMemory
924796boris_mihovPoi (IOI09_poi)C++17
100 / 100
176 ms24152 KiB
#include <algorithm> #include <iostream> #include <numeric> #include <cassert> #include <vector> typedef long long llong; const int MAXN = 2000 + 10; const int INF = 1e9; int n, m, p; int sum[MAXN]; int score[MAXN]; int cntTasks[MAXN]; int a[MAXN][MAXN]; int order[MAXN]; void solve() { for (int i = 1 ; i <= n ; ++i) { for (int j = 1 ; j <= m ; ++j) { sum[j] += !a[i][j]; } } for (int i = 1 ; i <= n ; ++i) { for (int j = 1 ; j <= m ; ++j) { score[i] += (a[i][j] == 1) * sum[j]; cntTasks[i] += (a[i][j] == 1); } } std::iota(order + 1, order + 1 + n, 1); std::sort(order + 1, order + 1 + n, [&](int x, int y) { return score[x] > score[y] || (score[x] == score[y] && cntTasks[x] > cntTasks[y]) || (score[x] == score[y] && cntTasks[x] == cntTasks[y] && x < y); }); for (int i = 1 ; i <= n ; ++i) { if (order[i] == p) { std::cout << score[p] << ' ' << i << '\n'; return; } } assert(false); } void input() { std::cin >> n >> m >> p; for (int i = 1 ; i <= n ; ++i) { for (int j = 1 ; j <= m ; ++j) { std::cin >> a[i][j]; } } } void fastIOI() { std::ios_base :: sync_with_stdio(0); std::cout.tie(nullptr); std::cin.tie(nullptr); } int main() { fastIOI(); input(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...