Submission #1315827

#TimeUsernameProblemLanguageResultExecution timeMemory
1315827nguyenkhangninh99Topical (NOI23_topical)C++20
100 / 100
561 ms133488 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; vector<vector<int>> r(n + 1, vector<int>(k + 1)), u(n + 1, vector<int>(k + 1)); vector<priority_queue<pair<int, int>>> pq(k + 1); for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++){ cin >> r[i][j]; pq[j].push({-r[i][j], i}); } } for(int i = 1; i <= n; i++){ for(int j = 1; j <= k; j++) cin >> u[i][j]; } vector<int> p(k + 1), at(n + 1); for(int loop = 1; loop <= n + 1; loop++){ for(int j = 1; j <= k; j++){ while(pq[j].size() && -(pq[j].top().first) <= p[j]){ auto [_, id] = pq[j].top(); pq[j].pop(); at[id]++; if(at[id] == k){ for(int z = 1; z <= k; z++) p[z] += u[id][z]; } } } } int res = 0; for(int i = 1; i <= n; i++) if(at[i] == k) res++; cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...