Submission #1123255

#TimeUsernameProblemLanguageResultExecution timeMemory
1123255AvianshTopical (NOI23_topical)C++20
0 / 100
3 ms580 KiB
#include <bits/stdc++.h> using namespace std; signed main(){ ios::sync_with_stdio(0); cin.tie(0); int n,k; cin >> n >> k; int r[n][k]; int u[n][k]; pair<int,int>sortedreqs[k][n]; for(int i = 0;i<n;i++){ for(int j = 0;j<k;j++){ cin >> r[i][j]; sortedreqs[j][i]={r[i][j],i}; } } for(int i = 0;i<n;i++){ for(int j = 0;j<k;j++){ cin >> u[i][j]; } } for(int i = 0;i<k;i++){ sort(sortedreqs[i],sortedreqs[i]+n); } int cur[k]; int val[n]; fill(val,val+n,0); fill(cur,cur+k,0); int cn = 0; int inds[k]; fill(inds,inds+k,0); while(cn<n){ int curcn = 0; for(int i = 0;i<k;i++){ bool fn=0; while(cur[i]>=sortedreqs[i][inds[i]].first){ val[sortedreqs[i][inds[i]].second]++; inds[i]++; if(val[sortedreqs[i][inds[i]-1].second]==k){ fn=1; int c = inds[i]-1; for(int i = 0;i<k;i++){ cur[i]+=u[sortedreqs[i][c].second][i]; } break; } } if(fn){ curcn++; break; } } if(curcn){ cn+=curcn; } else{ break; } } cout << cn; 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...