Submission #1272687

#TimeUsernameProblemLanguageResultExecution timeMemory
1272687marshziinTopical (NOI23_topical)C++20
100 / 100
334 ms121580 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, k; cin >> n >> k; vector<vector<int>> r(n + 1, vector<int>(k + 1)); vector<vector<int>> u(n + 1, vector<int>(k + 1)); vector<vector<pii>> list(k + 1, vector<pii>(1, {0,0})); for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { cin >> r[i][j]; list[j].push_back({r[i][j], i}); } } for (int i = 1; i <= k; i++) sort(list[i].begin(), list[i].end()); for (int i = 1; i <= n; i++) for (int j = 1; j <= k; j++) cin >> u[i][j]; vector<int> cnt(n + 1); vector<long long> curK(k + 1); int res = 0; vector<int> poss(k + 1, 1); while(true) { bool found = false; for (int i = 1; i <= k; i++) { while(poss[i] < (int)list[i].size()) { auto it = list[i].begin(); int tax = list[i][poss[i]].first, pos = list[i][poss[i]].second; if(tax > curK[i]) break; cnt[pos]++; poss[i]++; if(cnt[pos] == k) { for (int j = 1; j <= k; j++) curK[j] += u[pos][j]; found = true; res++; } } } if(!found) break; } cout << res << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...