Submission #1272679

#TimeUsernameProblemLanguageResultExecution timeMemory
1272679marshziinTopical (NOI23_topical)C++20
40 / 100
1103 ms156892 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<set<pii>> list(k + 1); for (int i = 1; i <= n; i++) { for (int j = 1; j <= k; j++) { cin >> r[i][j]; list[j].insert({r[i][j], i}); } } for (int i = 1; i <= n; i++) for (int j = 1; j <= k; j++) cin >> u[i][j]; map<int,int> cnt; vector<long long> curK(k + 1); int res = 0; while(true) { bool found = false; for (int i = 1; i <= k; i++) { while(!list[i].empty()) { auto it = list[i].begin(); int tax = it->first, pos = it->second; if(tax > curK[i]) break; cnt[pos]++; list[i].erase(it); 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...