Submission #1099581

#TimeUsernameProblemLanguageResultExecution timeMemory
1099581coin_Topical (NOI23_topical)C++14
100 / 100
393 ms211108 KiB
#include <bits/stdc++.h> #define int long long #define fi first #define se second #define endl '\n' using namespace std; signed main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); int n, k; cin >> n >> k; vector<vector<int>> req(n, vector<int>(k + 5, 0)), gain(n + 5, vector<int>(k + 5, 0)); vector<vector<pair<int, int>>> sortedreq(k + 5, vector<pair<int, int>>()); vector<int> count(n + 5, 0), cur(k + 5, 0), track(k + 5, 0); for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ cin >> req[i][j]; sortedreq[j].push_back({req[i][j], i}); } } for (int i = 0; i < n; i++){ for (int j = 0; j < k; j++){ cin >> gain[i][j]; } } for (int j = 0; j < k; j++){ sort(sortedreq[j].begin(), sortedreq[j].end()); } int ans = 0; while(true){ int change = 0; for (int j = 0; j < k; j++){ while(track[j] < n && cur[j] >= sortedreq[j][track[j]].fi){ change = 1; int module = sortedreq[j][track[j]].se; count[module]++; if (count[module] == k){ ans++; for (int _ = 0; _ < k; _++){ cur[_] += gain[module][_]; } } track[j]++; } } if (change == 0) break; } 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...