# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
914125 |
2024-01-21T08:25:44 Z |
vjudge1 |
Topical (NOI23_topical) |
C++17 |
|
450 ms |
151484 KB |
#include<bits/stdc++.h>
using namespace std;
void solve(){
int n, k; cin >> n >> k;
vector<vector<int>> r(n, vector<int>(k));
vector<vector<int>> u(n, vector<int>(k));
for(vector<int>&v : r){
for(int& x : v) cin >> x;
}
for(vector<int>&v : u){
for(int& x : v) cin >> x;
}
r.push_back(vector<int>(k, 0));
u.push_back(vector<int>(k, 0));
vector<vector<pair<int, int>>> topics(k);
for(int j = 0; j < k; j++){
for(int i = 0; i < n; i++){
topics[j].push_back({r[i][j], i});
}
sort(topics[j].begin(), topics[j].end());
}
vector<int> lst(k, -1), cnt(n, 0);
queue<int> q; q.push(n);
vector<int> curr(k, 0);
int ans = 0;
// cerr << "here" << endl;
while(!q.empty()){
int x = q.front(); q.pop();
ans++;
for(int i = 0; i < k; i++){
curr[i] += u[x][i];
int nw = lst[i]+1;
while(nw < n && topics[i][nw].first <= curr[i]){
lst[i]=nw;
cnt[topics[i][nw].second]++;
if(cnt[topics[i][nw].second] == k) q.push(topics[i][nw].second);
nw++;
}
}
}
cout << ans - 1 << "\n";
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
// int tt; cin >> tt;
int tt = 1;
while(tt--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
1368 KB |
Output is correct |
4 |
Correct |
189 ms |
90124 KB |
Output is correct |
5 |
Correct |
187 ms |
90336 KB |
Output is correct |
6 |
Correct |
198 ms |
90264 KB |
Output is correct |
7 |
Correct |
170 ms |
84492 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 |
0 ms |
456 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
3 ms |
604 KB |
Output is correct |
8 |
Correct |
2 ms |
720 KB |
Output is correct |
9 |
Correct |
2 ms |
644 KB |
Output is correct |
10 |
Correct |
3 ms |
600 KB |
Output is correct |
11 |
Correct |
2 ms |
732 KB |
Output is correct |
12 |
Correct |
3 ms |
732 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
1924 KB |
Output is correct |
4 |
Correct |
43 ms |
15968 KB |
Output is correct |
5 |
Correct |
41 ms |
17196 KB |
Output is correct |
6 |
Correct |
443 ms |
149556 KB |
Output is correct |
7 |
Correct |
432 ms |
148416 KB |
Output is correct |
8 |
Correct |
450 ms |
151484 KB |
Output is correct |
9 |
Correct |
426 ms |
149688 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
344 KB |
Output is correct |
3 |
Correct |
3 ms |
1368 KB |
Output is correct |
4 |
Correct |
189 ms |
90124 KB |
Output is correct |
5 |
Correct |
187 ms |
90336 KB |
Output is correct |
6 |
Correct |
198 ms |
90264 KB |
Output is correct |
7 |
Correct |
170 ms |
84492 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
456 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
604 KB |
Output is correct |
15 |
Correct |
2 ms |
720 KB |
Output is correct |
16 |
Correct |
2 ms |
644 KB |
Output is correct |
17 |
Correct |
3 ms |
600 KB |
Output is correct |
18 |
Correct |
2 ms |
732 KB |
Output is correct |
19 |
Correct |
3 ms |
732 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
0 ms |
348 KB |
Output is correct |
22 |
Correct |
4 ms |
1924 KB |
Output is correct |
23 |
Correct |
43 ms |
15968 KB |
Output is correct |
24 |
Correct |
41 ms |
17196 KB |
Output is correct |
25 |
Correct |
443 ms |
149556 KB |
Output is correct |
26 |
Correct |
432 ms |
148416 KB |
Output is correct |
27 |
Correct |
450 ms |
151484 KB |
Output is correct |
28 |
Correct |
426 ms |
149688 KB |
Output is correct |
29 |
Correct |
212 ms |
36840 KB |
Output is correct |
30 |
Correct |
207 ms |
33432 KB |
Output is correct |
31 |
Correct |
253 ms |
38908 KB |
Output is correct |
32 |
Correct |
160 ms |
27620 KB |
Output is correct |
33 |
Correct |
173 ms |
26252 KB |
Output is correct |
34 |
Correct |
209 ms |
27252 KB |
Output is correct |
35 |
Correct |
237 ms |
36004 KB |
Output is correct |
36 |
Correct |
208 ms |
30520 KB |
Output is correct |
37 |
Correct |
229 ms |
33408 KB |
Output is correct |
38 |
Correct |
159 ms |
29692 KB |
Output is correct |