Submission #1132453

#TimeUsernameProblemLanguageResultExecution timeMemory
1132453lopkusCouncil (JOI23_council)C++20
16 / 100
4094 ms9848 KiB
#include <bits/stdc++.h> #define int long long using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; int a[n + 1][m + 1]; for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cin >> a[i][j]; } } vector<int> cnt(m + 1, 0); for(int i = 1; i <= n; i++) { for(int j = 1; j <= m; j++) { cnt[j] += a[i][j]; } } int K = (n - 2) / 2; for(int i = 1; i <= n; i++) { int ans = 0; vector<int> V; for(int j = 1; j <= m; j++) { if(cnt[j] - a[i][j] > K + 1) { ans += 1; continue; } // at least k + 2 // if cnt[j] - a[i][j] < k + 1 this is imposible // if cnt[j] - a[i][j] == k + 1 that is posible but... if(cnt[j] - a[i][j] < K + 1) { continue; } V.push_back(j); } vector<int> c(n + 1, 0); for(auto it : V) { for(int j = 1; j <= n; j++) { c[j] += a[j][it]; } } int mx = m + 1; for(int j = 1; j <= n; j++) { if(j == i) { continue; } mx = min(mx, c[j]); } ans += V.size() - mx; cout << ans << "\n"; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...