# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1016654 |
2024-07-08T09:57:24 Z |
Salty |
Topical (NOI23_topical) |
C++14 |
|
663 ms |
138592 KB |
#include<bits/stdc++.h>
#define ll long long
#define st first
#define nd second
#define pii pair<int,int>
using namespace std;
int main(){
int n,k;
cin >> n >> k;
vector<vector<int>> u(n,vector<int>(k)),r(n,vector<int>(k));
for(int i = 0; i < n; i++)for(int j = 0; j < k; j++) cin >> r[i][j];
for(int i = 0; i < n; i++)for(int j = 0; j < k; j++) cin >> u[i][j];
vector<int> cur (k,0), cntcol(k,0), cntrow(n,0), use(n,0);
vector<pii> vec[k];
queue<int> q;
int ans = 0;
for(int i = 0; i < n; i++){
bool can = true;
for(int j = 0; j < k; j++){
if(r[i][j] > 0) can = false;
vec[j].push_back({r[i][j],i});
}
if(can){
q.push(i);
use[i] = 1;
}
}
for(int i = 0; i < k; i++)sort(vec[i].begin(),vec[i].end());
while(!q.empty()){
int fr = q.front();
ans++;
q.pop();
for(int i = 0; i < k; i++){
cur[i] += u[fr][i];
while(cntcol[i] < n && vec[i][cntcol[i]].st <= cur[i]){
cntrow[vec[i][cntcol[i]].nd]++;
if(cntrow[vec[i][cntcol[i]].nd] == k && !use[vec[i][cntcol[i]].nd]){
q.push(vec[i][cntcol[i]].nd);
use[vec[i][cntcol[i]].nd] = 1;
}
cntcol[i]++;
}
}
}
cout << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
1116 KB |
Output is correct |
4 |
Correct |
407 ms |
79900 KB |
Output is correct |
5 |
Correct |
416 ms |
80052 KB |
Output is correct |
6 |
Correct |
420 ms |
79928 KB |
Output is correct |
7 |
Correct |
270 ms |
75276 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
436 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
6 ms |
704 KB |
Output is correct |
8 |
Correct |
6 ms |
632 KB |
Output is correct |
9 |
Correct |
4 ms |
600 KB |
Output is correct |
10 |
Correct |
5 ms |
696 KB |
Output is correct |
11 |
Correct |
10 ms |
604 KB |
Output is correct |
12 |
Correct |
6 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
6 ms |
1820 KB |
Output is correct |
4 |
Correct |
59 ms |
14796 KB |
Output is correct |
5 |
Correct |
54 ms |
14548 KB |
Output is correct |
6 |
Correct |
663 ms |
138488 KB |
Output is correct |
7 |
Correct |
623 ms |
138404 KB |
Output is correct |
8 |
Correct |
656 ms |
138592 KB |
Output is correct |
9 |
Correct |
602 ms |
137412 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
1116 KB |
Output is correct |
4 |
Correct |
407 ms |
79900 KB |
Output is correct |
5 |
Correct |
416 ms |
80052 KB |
Output is correct |
6 |
Correct |
420 ms |
79928 KB |
Output is correct |
7 |
Correct |
270 ms |
75276 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
1 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
436 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
6 ms |
704 KB |
Output is correct |
15 |
Correct |
6 ms |
632 KB |
Output is correct |
16 |
Correct |
4 ms |
600 KB |
Output is correct |
17 |
Correct |
5 ms |
696 KB |
Output is correct |
18 |
Correct |
10 ms |
604 KB |
Output is correct |
19 |
Correct |
6 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
6 ms |
1820 KB |
Output is correct |
23 |
Correct |
59 ms |
14796 KB |
Output is correct |
24 |
Correct |
54 ms |
14548 KB |
Output is correct |
25 |
Correct |
663 ms |
138488 KB |
Output is correct |
26 |
Correct |
623 ms |
138404 KB |
Output is correct |
27 |
Correct |
656 ms |
138592 KB |
Output is correct |
28 |
Correct |
602 ms |
137412 KB |
Output is correct |
29 |
Correct |
513 ms |
32440 KB |
Output is correct |
30 |
Correct |
494 ms |
29692 KB |
Output is correct |
31 |
Correct |
510 ms |
34956 KB |
Output is correct |
32 |
Correct |
320 ms |
25632 KB |
Output is correct |
33 |
Correct |
345 ms |
24404 KB |
Output is correct |
34 |
Correct |
376 ms |
27332 KB |
Output is correct |
35 |
Correct |
450 ms |
32748 KB |
Output is correct |
36 |
Correct |
406 ms |
29596 KB |
Output is correct |
37 |
Correct |
504 ms |
32084 KB |
Output is correct |
38 |
Correct |
244 ms |
26708 KB |
Output is correct |