Submission #1127791

#TimeUsernameProblemLanguageResultExecution timeMemory
1127791pemguimnTopical (NOI23_topical)C++17
12 / 100
230 ms70752 KiB
#include <bits/stdc++.h> #define pii pair<int, int> using namespace std; const int N = 1e6 + 5; int n, k, cnt[N], it[N], pw[N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; vector<vector<pii>> a(k); vector<vector<int>> v(n, vector<int>(k)); for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ int x; cin >> x; a[j].push_back({x, i}); } } for(int i = 0; i < k; i++){ sort(a[i].begin(), a[i].end()); cnt[i] = 0; } for(int i = 0; i < n; i++){ for(int j = 0; j < k; j++){ cin >> v[i][j]; } } int ans = 0; for(int i = 0; i < n; i++){ bool inc = false; for(int j = 0; j < k; j++){ if(it[j] == n) continue; while(it[j] < n && a[j][it[j]].first <= pw[j]){ int id = a[j][it[j]].second; cnt[id]++, it[j]++; if(cnt[id] == k){ ans++, inc = true; for(int l = 0; l < k; l++) pw[l] += v[id][l]; } } } } cout << ans << '\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...