# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
914155 |
2024-01-21T10:00:22 Z |
vjudge1 |
Topical (NOI23_topical) |
C++17 |
|
522 ms |
136364 KB |
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math,inline")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,lzcnt,mmx,abm,avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define int long long
bool cmp(pair<int,int> a, pair<int,int> b){
return a.second < b.second;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n,k; cin>>n>>k;
vector<vector<int>> r(n,vector<int>(k,0)); auto u = r;
for(auto& x : r){
for(auto& i : x) cin>>i;
}
for(auto& x : u){
for(auto& i : x) cin>>i;
}
vector<vector<pair<int,int>>> idx(k);
vector<int> pt(k);
for(int i = 0; i<k; i++){
for(int j = 0; j<n; j++){
idx[i].push_back({r[j][i], j});
}
sort(idx[i].begin(), idx[i].end());
// can go from i to i+1 if and only if in this topic if r[i][j] + u[i][j] >= r[z][j]
}
queue<int> q; q.push(-1);
vector<int> act(k); vector<int> used(n);
vector<int> PT(k,0);
int ans = 0;
while(!q.empty()){
int u1 = q.front(); q.pop();
if(u1 >= 0) ans++;
for(int i = 0; i<k; i++){
if(u1 >= 0) act[i] += u[u1][i];
if(PT[i] == n) continue;
if(idx[i][PT[i]].first > act[i]) continue;
while(PT[i] < n && idx[i][PT[i]].first <= act[i]){
// cerr<<"! "<<i<<" "<<idx[i][PT[i]].second<<endl;
used[idx[i][PT[i]].second]++;
// if all used, q.push
if(used[idx[i][PT[i]].second] == k) q.push(idx[i][PT[i]].second);
PT[i]++;
}
}
}
cout<<ans<<endl;
}
# |
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 |
3 ms |
1372 KB |
Output is correct |
4 |
Correct |
188 ms |
94180 KB |
Output is correct |
5 |
Correct |
192 ms |
94180 KB |
Output is correct |
6 |
Correct |
212 ms |
94152 KB |
Output is correct |
7 |
Correct |
158 ms |
94188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
344 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
604 KB |
Output is correct |
9 |
Correct |
2 ms |
604 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
3 ms |
600 KB |
Output is correct |
12 |
Correct |
3 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
5 ms |
1880 KB |
Output is correct |
4 |
Correct |
44 ms |
13600 KB |
Output is correct |
5 |
Correct |
38 ms |
13768 KB |
Output is correct |
6 |
Correct |
522 ms |
136364 KB |
Output is correct |
7 |
Correct |
466 ms |
133288 KB |
Output is correct |
8 |
Correct |
501 ms |
136324 KB |
Output is correct |
9 |
Correct |
462 ms |
133800 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 |
3 ms |
1372 KB |
Output is correct |
4 |
Correct |
188 ms |
94180 KB |
Output is correct |
5 |
Correct |
192 ms |
94180 KB |
Output is correct |
6 |
Correct |
212 ms |
94152 KB |
Output is correct |
7 |
Correct |
158 ms |
94188 KB |
Output is correct |
8 |
Correct |
0 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 |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
344 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
604 KB |
Output is correct |
16 |
Correct |
2 ms |
604 KB |
Output is correct |
17 |
Correct |
3 ms |
600 KB |
Output is correct |
18 |
Correct |
3 ms |
600 KB |
Output is correct |
19 |
Correct |
3 ms |
604 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
348 KB |
Output is correct |
22 |
Correct |
5 ms |
1880 KB |
Output is correct |
23 |
Correct |
44 ms |
13600 KB |
Output is correct |
24 |
Correct |
38 ms |
13768 KB |
Output is correct |
25 |
Correct |
522 ms |
136364 KB |
Output is correct |
26 |
Correct |
466 ms |
133288 KB |
Output is correct |
27 |
Correct |
501 ms |
136324 KB |
Output is correct |
28 |
Correct |
462 ms |
133800 KB |
Output is correct |
29 |
Correct |
232 ms |
36608 KB |
Output is correct |
30 |
Correct |
236 ms |
32148 KB |
Output is correct |
31 |
Correct |
316 ms |
41132 KB |
Output is correct |
32 |
Correct |
176 ms |
36704 KB |
Output is correct |
33 |
Correct |
201 ms |
32176 KB |
Output is correct |
34 |
Correct |
242 ms |
33108 KB |
Output is correct |
35 |
Correct |
279 ms |
40880 KB |
Output is correct |
36 |
Correct |
237 ms |
32992 KB |
Output is correct |
37 |
Correct |
266 ms |
33016 KB |
Output is correct |
38 |
Correct |
211 ms |
40924 KB |
Output is correct |