Submission #1173569

#TimeUsernameProblemLanguageResultExecution timeMemory
1173569PenguinsAreCuteTopical (NOI23_topical)C++20
100 / 100
204 ms39576 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int> ii; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k, ans = 0; bool ok = true; cin >> n >> k; ii r[k][n]; int u[n][k], cnt[n], skill[k], ptr[k]; memset(skill, 0, sizeof(skill)); memset(ptr, 0, sizeof(ptr)); memset(cnt, 0, sizeof(cnt)); for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) { cin >> r[j][i].first; r[j][i].second = i; } for(int i = 0; i < n; i++) for(int j = 0; j < k; j++) cin >> u[i][j]; for(int j = 0; j < k; j++) sort(r[j], r[j] + n); while(ok) { ok = false; for(int i = 0; i < k; i++) { while(ptr[i] != n && r[i][ptr[i]].first <= skill[i]) { cnt[r[i][ptr[i]].second]++; if(cnt[r[i][ptr[i]].second] == k) { ans++; for(int j = 0; j < k; j++) skill[j] += u[r[i][ptr[i]].second][j]; } ptr[i]++; ok = true; } } } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...