# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
519436 |
2022-01-26T11:00:30 Z |
Jomnoi |
Lasers (NOI19_lasers) |
C++17 |
|
167 ms |
58464 KB |
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;
int main() {
cin.tie(0)->sync_with_stdio(0);
int L, R;
cin >> L >> R;
vector <vector <int>> qs(R + 10);
vector <int> sz(R + 10);
for(int i = 1; i <= R; i++) {
int X;
cin >> X;
sz[i] = X;
qs[i].resize(X + 10, 0);
for(int j = 1; j <= X; j++) {
int a;
cin >> a;
qs[i][j] = qs[i][j - 1] + a;
}
}
vector <pair <int, int>> vec;
for(int i = 1; i <= R; i++) {
for(int j = 1; j <= sz[i]; j++) {
int a = qs[i][j] - qs[i][j - 1];
int pos_left = qs[i][j - 1] + 1;
int pos_right = L - (qs[i][sz[i]] - qs[i][j]);
if(pos_left + a - 1 < pos_right - a + 1) {
continue;
}
vec.emplace_back(pos_right - a + 1, 1);
vec.emplace_back(pos_left + a, -1);
}
}
sort(vec.begin(), vec.end());
int ans = 0, left = -1, sum = 0;
for(auto [v, d] : vec) {
sum += d;
if(left == -1) {
left = v;
}
if(sum == 0) {
ans += v - left;
left = -1;
}
}
cout << ans;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
156 ms |
58464 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
149 ms |
55004 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
5664 KB |
Output is correct |
2 |
Correct |
9 ms |
1356 KB |
Output is correct |
3 |
Correct |
8 ms |
1232 KB |
Output is correct |
4 |
Correct |
45 ms |
6376 KB |
Output is correct |
5 |
Correct |
25 ms |
3392 KB |
Output is correct |
6 |
Correct |
33 ms |
3768 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
28 ms |
4164 KB |
Output is correct |
9 |
Correct |
21 ms |
5564 KB |
Output is correct |
10 |
Correct |
50 ms |
6500 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
332 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
0 ms |
312 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
39 ms |
5664 KB |
Output is correct |
2 |
Correct |
9 ms |
1356 KB |
Output is correct |
3 |
Correct |
8 ms |
1232 KB |
Output is correct |
4 |
Correct |
45 ms |
6376 KB |
Output is correct |
5 |
Correct |
25 ms |
3392 KB |
Output is correct |
6 |
Correct |
33 ms |
3768 KB |
Output is correct |
7 |
Correct |
1 ms |
460 KB |
Output is correct |
8 |
Correct |
28 ms |
4164 KB |
Output is correct |
9 |
Correct |
21 ms |
5564 KB |
Output is correct |
10 |
Correct |
50 ms |
6500 KB |
Output is correct |
11 |
Correct |
0 ms |
332 KB |
Output is correct |
12 |
Correct |
0 ms |
204 KB |
Output is correct |
13 |
Correct |
1 ms |
204 KB |
Output is correct |
14 |
Correct |
1 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
204 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
1 ms |
332 KB |
Output is correct |
18 |
Correct |
1 ms |
332 KB |
Output is correct |
19 |
Correct |
1 ms |
332 KB |
Output is correct |
20 |
Correct |
0 ms |
312 KB |
Output is correct |
21 |
Correct |
157 ms |
53412 KB |
Output is correct |
22 |
Correct |
22 ms |
2532 KB |
Output is correct |
23 |
Correct |
11 ms |
2096 KB |
Output is correct |
24 |
Correct |
43 ms |
7348 KB |
Output is correct |
25 |
Correct |
152 ms |
53456 KB |
Output is correct |
26 |
Correct |
38 ms |
6792 KB |
Output is correct |
27 |
Correct |
15 ms |
2372 KB |
Output is correct |
28 |
Correct |
152 ms |
53276 KB |
Output is correct |
29 |
Correct |
151 ms |
53568 KB |
Output is correct |
30 |
Correct |
46 ms |
4636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
0 ms |
204 KB |
Output is correct |
4 |
Correct |
0 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
312 KB |
Output is correct |
6 |
Correct |
0 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
0 ms |
204 KB |
Output is correct |
9 |
Correct |
0 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
156 ms |
58464 KB |
Output is correct |
13 |
Correct |
0 ms |
204 KB |
Output is correct |
14 |
Correct |
0 ms |
204 KB |
Output is correct |
15 |
Correct |
1 ms |
332 KB |
Output is correct |
16 |
Correct |
1 ms |
332 KB |
Output is correct |
17 |
Correct |
149 ms |
55004 KB |
Output is correct |
18 |
Correct |
1 ms |
204 KB |
Output is correct |
19 |
Correct |
1 ms |
204 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
39 ms |
5664 KB |
Output is correct |
22 |
Correct |
9 ms |
1356 KB |
Output is correct |
23 |
Correct |
8 ms |
1232 KB |
Output is correct |
24 |
Correct |
45 ms |
6376 KB |
Output is correct |
25 |
Correct |
25 ms |
3392 KB |
Output is correct |
26 |
Correct |
33 ms |
3768 KB |
Output is correct |
27 |
Correct |
1 ms |
460 KB |
Output is correct |
28 |
Correct |
28 ms |
4164 KB |
Output is correct |
29 |
Correct |
21 ms |
5564 KB |
Output is correct |
30 |
Correct |
50 ms |
6500 KB |
Output is correct |
31 |
Correct |
0 ms |
332 KB |
Output is correct |
32 |
Correct |
0 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
332 KB |
Output is correct |
37 |
Correct |
1 ms |
332 KB |
Output is correct |
38 |
Correct |
1 ms |
332 KB |
Output is correct |
39 |
Correct |
1 ms |
332 KB |
Output is correct |
40 |
Correct |
0 ms |
312 KB |
Output is correct |
41 |
Correct |
157 ms |
53412 KB |
Output is correct |
42 |
Correct |
22 ms |
2532 KB |
Output is correct |
43 |
Correct |
11 ms |
2096 KB |
Output is correct |
44 |
Correct |
43 ms |
7348 KB |
Output is correct |
45 |
Correct |
152 ms |
53456 KB |
Output is correct |
46 |
Correct |
38 ms |
6792 KB |
Output is correct |
47 |
Correct |
15 ms |
2372 KB |
Output is correct |
48 |
Correct |
152 ms |
53276 KB |
Output is correct |
49 |
Correct |
151 ms |
53568 KB |
Output is correct |
50 |
Correct |
46 ms |
4636 KB |
Output is correct |
51 |
Correct |
16 ms |
2500 KB |
Output is correct |
52 |
Correct |
167 ms |
54424 KB |
Output is correct |
53 |
Correct |
162 ms |
54516 KB |
Output is correct |
54 |
Correct |
30 ms |
4788 KB |
Output is correct |
55 |
Correct |
74 ms |
9592 KB |
Output is correct |
56 |
Correct |
43 ms |
7384 KB |
Output is correct |
57 |
Correct |
48 ms |
7788 KB |
Output is correct |
58 |
Correct |
160 ms |
54928 KB |
Output is correct |
59 |
Correct |
34 ms |
4804 KB |
Output is correct |
60 |
Correct |
48 ms |
5936 KB |
Output is correct |