#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mxnk=5e6+5,mxn=mxnk,mxk=mxnk;
int R[mxnk],U[mxnk];
int n,k;
#define r(i,j) R[i*k+j]
#define u(i,j) U[i*k+j]
int filled[mxn];//for each task, how many requirements fulfilled
int cur[mxk];//for each topic, current knowledge...
#define f first
#define s second
vector<pair<int,int> > reqs[mxk];//for each topic, store (requirement, task index)
int ind[mxk];//index of next req to hit in reqs...
int32_t main(){
ios_base::sync_with_stdio(false);cin.tie(0);
cin>>n>>k;
for(int i=0;i<n;i++){
for(int j=0;j<k;j++){
cin>>r(i,j);
reqs[j].emplace_back(r(i,j),i);
}
}
for(int j=0;j<k;j++)sort(reqs[j].begin(),reqs[j].end());
for(int i=0;i<n;i++){
for(int j=0;j<k;j++)cin>>u(i,j);
}
int ans=0;
vector<int>nex;
bool can=1;
while(can){
can=0;
for(int j=0;j<k;j++){
while(ind[j]<n && reqs[j][ind[j]].f<=cur[j]){
filled[reqs[j][ind[j]].s]++;
if(filled[reqs[j][ind[j]].s]==k){
// nex.push_back(reqs[j][ind[j]].s);
// int x=reqs[j][ind[j]].s;
for(int jj=0;jj<k;jj++){
cur[jj]+=u(reqs[j][ind[j]].s,jj);
}
ans++;
can=1;
}
ind[j]++;
}
}
// if(nex.size()==0)break;
// while(nex.size()>0){
// }
}
cout<<ans;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
117748 KB |
Output is correct |
2 |
Correct |
59 ms |
117712 KB |
Output is correct |
3 |
Correct |
73 ms |
118420 KB |
Output is correct |
4 |
Correct |
258 ms |
191056 KB |
Output is correct |
5 |
Correct |
319 ms |
189868 KB |
Output is correct |
6 |
Correct |
264 ms |
189716 KB |
Output is correct |
7 |
Correct |
237 ms |
165732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
73 ms |
117652 KB |
Output is correct |
2 |
Correct |
71 ms |
117672 KB |
Output is correct |
3 |
Correct |
65 ms |
117700 KB |
Output is correct |
4 |
Correct |
70 ms |
117656 KB |
Output is correct |
5 |
Correct |
74 ms |
117668 KB |
Output is correct |
6 |
Correct |
64 ms |
117756 KB |
Output is correct |
7 |
Correct |
71 ms |
118240 KB |
Output is correct |
8 |
Correct |
75 ms |
118156 KB |
Output is correct |
9 |
Correct |
71 ms |
118128 KB |
Output is correct |
10 |
Correct |
77 ms |
118196 KB |
Output is correct |
11 |
Correct |
73 ms |
118192 KB |
Output is correct |
12 |
Correct |
76 ms |
118264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
69 ms |
117688 KB |
Output is correct |
2 |
Correct |
72 ms |
117752 KB |
Output is correct |
3 |
Correct |
69 ms |
118308 KB |
Output is correct |
4 |
Correct |
102 ms |
123256 KB |
Output is correct |
5 |
Correct |
88 ms |
122952 KB |
Output is correct |
6 |
Correct |
369 ms |
166784 KB |
Output is correct |
7 |
Correct |
384 ms |
164620 KB |
Output is correct |
8 |
Correct |
401 ms |
160448 KB |
Output is correct |
9 |
Correct |
359 ms |
156992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
71 ms |
117748 KB |
Output is correct |
2 |
Correct |
59 ms |
117712 KB |
Output is correct |
3 |
Correct |
73 ms |
118420 KB |
Output is correct |
4 |
Correct |
258 ms |
191056 KB |
Output is correct |
5 |
Correct |
319 ms |
189868 KB |
Output is correct |
6 |
Correct |
264 ms |
189716 KB |
Output is correct |
7 |
Correct |
237 ms |
165732 KB |
Output is correct |
8 |
Correct |
73 ms |
117652 KB |
Output is correct |
9 |
Correct |
71 ms |
117672 KB |
Output is correct |
10 |
Correct |
65 ms |
117700 KB |
Output is correct |
11 |
Correct |
70 ms |
117656 KB |
Output is correct |
12 |
Correct |
74 ms |
117668 KB |
Output is correct |
13 |
Correct |
64 ms |
117756 KB |
Output is correct |
14 |
Correct |
71 ms |
118240 KB |
Output is correct |
15 |
Correct |
75 ms |
118156 KB |
Output is correct |
16 |
Correct |
71 ms |
118128 KB |
Output is correct |
17 |
Correct |
77 ms |
118196 KB |
Output is correct |
18 |
Correct |
73 ms |
118192 KB |
Output is correct |
19 |
Correct |
76 ms |
118264 KB |
Output is correct |
20 |
Correct |
69 ms |
117688 KB |
Output is correct |
21 |
Correct |
72 ms |
117752 KB |
Output is correct |
22 |
Correct |
69 ms |
118308 KB |
Output is correct |
23 |
Correct |
102 ms |
123256 KB |
Output is correct |
24 |
Correct |
88 ms |
122952 KB |
Output is correct |
25 |
Correct |
369 ms |
166784 KB |
Output is correct |
26 |
Correct |
384 ms |
164620 KB |
Output is correct |
27 |
Correct |
401 ms |
160448 KB |
Output is correct |
28 |
Correct |
359 ms |
156992 KB |
Output is correct |
29 |
Correct |
370 ms |
153772 KB |
Output is correct |
30 |
Correct |
316 ms |
149552 KB |
Output is correct |
31 |
Correct |
340 ms |
150160 KB |
Output is correct |
32 |
Correct |
259 ms |
153804 KB |
Output is correct |
33 |
Correct |
309 ms |
149580 KB |
Output is correct |
34 |
Correct |
293 ms |
152200 KB |
Output is correct |
35 |
Correct |
296 ms |
150164 KB |
Output is correct |
36 |
Correct |
308 ms |
152200 KB |
Output is correct |
37 |
Correct |
300 ms |
152276 KB |
Output is correct |
38 |
Correct |
230 ms |
150164 KB |
Output is correct |