Submission #1268290

#TimeUsernameProblemLanguageResultExecution timeMemory
1268290vukhacminhTopical (NOI23_topical)C++20
12 / 100
165 ms70768 KiB
/** * Author : Vu Khac Minh **/ #include <bits/stdc++.h> using namespace std; #define ll long long const int maxn = 1e6 + 5; const int mod = 1e9+7; int n,k; vector<int> a[maxn], b[maxn]; vector<pair<int,int>> s[maxn]; int r[maxn], cnt[maxn], po[maxn]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>k; for(int i = 1;i<=n;i++) { a[i].resize(k+1); b[i].resize(k+1); } for(int i = 1;i<=n;i++) { for(int j = 1;j<=k;j++) { cin>>a[i][j]; s[j].push_back({a[i][j], i}); } } for(int i = 1;i<=n;i++) { for(int j = 1;j<=k;j++) cin>>b[i][j]; } for(int i = 1; i <= k; ++i) { sort(s[i].begin(), s[i].end()); } int res = 0; while(true) { bool stopped = false; for(int j = 1;j<=k;j++) { while(r[j] < (int)s[j].size()) { int x = s[j][r[j]].first; int y = s[j][r[j]].second; if(x <= po[j]) { r[j]++; cnt[y]++; if(cnt[y] == k) { for(int i = 1;i<=k;i++) po[i] += b[y][i]; stopped = true; res++; } } else break; } } if(!stopped) 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...