# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
970944 |
2024-04-27T14:55:04 Z |
jadai007 |
Lasers (NOI19_lasers) |
C++14 |
|
130 ms |
44056 KB |
#include <bits/stdc++.h>
using namespace std;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int L, R;
cin >> L >> R;
vector <int> sz(R + 1);
vector <vector <int>> walls(R + 1);
for (int i = 1; i <= R; i++) {
cin >> sz[i];
walls[i].resize(sz[i] + 1);
for (int j = 1; j <= sz[i]; j++) {
cin >> walls[i][j];
walls[i][j] += walls[i][j - 1];
}
}
vector <pair <int, int>> events;
for (int i = 1; i <= R; i++) {
for (int j = 1; j <= sz[i]; j++) {
int lm = walls[i][j - 1] + 1;
int rm = L - (walls[i][sz[i]] - walls[i][j]);
int cur = walls[i][j] - walls[i][j - 1];
if (rm - cur + 1 <= lm + cur - 1) {
events.emplace_back(rm - cur + 1, 1);
events.emplace_back(lm + cur, -1);
}
}
}
sort(events.begin(), events.end());
int lt = -1, ans = 0, sum = 0;
for (auto [x, v] : events) {
sum += v;
if (sum > 0 and lt == -1) lt = x;
else if (lt != -1 and sum == 0) ans += x - lt, lt = -1;
}
cout << ans;
return 0;
}
Compilation message
lasers.cpp: In function 'int main()':
lasers.cpp:38:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
38 | for (auto [x, v] : events) {
| ^
# |
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 |
348 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 |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 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 |
0 ms |
348 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 |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
110 ms |
44056 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
123 ms |
41644 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
7124 KB |
Output is correct |
2 |
Correct |
6 ms |
1500 KB |
Output is correct |
3 |
Correct |
7 ms |
1372 KB |
Output is correct |
4 |
Correct |
44 ms |
6612 KB |
Output is correct |
5 |
Correct |
18 ms |
3532 KB |
Output is correct |
6 |
Correct |
24 ms |
3892 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
26 ms |
4200 KB |
Output is correct |
9 |
Correct |
19 ms |
6100 KB |
Output is correct |
10 |
Correct |
43 ms |
8156 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 |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
456 KB |
Output is correct |
8 |
Correct |
1 ms |
352 KB |
Output is correct |
9 |
Correct |
1 ms |
464 KB |
Output is correct |
10 |
Correct |
1 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
7124 KB |
Output is correct |
2 |
Correct |
6 ms |
1500 KB |
Output is correct |
3 |
Correct |
7 ms |
1372 KB |
Output is correct |
4 |
Correct |
44 ms |
6612 KB |
Output is correct |
5 |
Correct |
18 ms |
3532 KB |
Output is correct |
6 |
Correct |
24 ms |
3892 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
26 ms |
4200 KB |
Output is correct |
9 |
Correct |
19 ms |
6100 KB |
Output is correct |
10 |
Correct |
43 ms |
8156 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 |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
0 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
0 ms |
456 KB |
Output is correct |
18 |
Correct |
1 ms |
352 KB |
Output is correct |
19 |
Correct |
1 ms |
464 KB |
Output is correct |
20 |
Correct |
1 ms |
344 KB |
Output is correct |
21 |
Correct |
128 ms |
39140 KB |
Output is correct |
22 |
Correct |
16 ms |
2776 KB |
Output is correct |
23 |
Correct |
10 ms |
2260 KB |
Output is correct |
24 |
Correct |
39 ms |
7612 KB |
Output is correct |
25 |
Correct |
122 ms |
39396 KB |
Output is correct |
26 |
Correct |
35 ms |
7884 KB |
Output is correct |
27 |
Correct |
13 ms |
2512 KB |
Output is correct |
28 |
Correct |
123 ms |
38456 KB |
Output is correct |
29 |
Correct |
121 ms |
39360 KB |
Output is correct |
30 |
Correct |
31 ms |
4812 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 |
348 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 |
600 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
344 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
1 ms |
604 KB |
Output is correct |
11 |
Correct |
1 ms |
348 KB |
Output is correct |
12 |
Correct |
110 ms |
44056 KB |
Output is correct |
13 |
Correct |
1 ms |
600 KB |
Output is correct |
14 |
Correct |
0 ms |
456 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
123 ms |
41644 KB |
Output is correct |
18 |
Correct |
0 ms |
344 KB |
Output is correct |
19 |
Correct |
0 ms |
348 KB |
Output is correct |
20 |
Correct |
0 ms |
348 KB |
Output is correct |
21 |
Correct |
37 ms |
7124 KB |
Output is correct |
22 |
Correct |
6 ms |
1500 KB |
Output is correct |
23 |
Correct |
7 ms |
1372 KB |
Output is correct |
24 |
Correct |
44 ms |
6612 KB |
Output is correct |
25 |
Correct |
18 ms |
3532 KB |
Output is correct |
26 |
Correct |
24 ms |
3892 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
26 ms |
4200 KB |
Output is correct |
29 |
Correct |
19 ms |
6100 KB |
Output is correct |
30 |
Correct |
43 ms |
8156 KB |
Output is correct |
31 |
Correct |
0 ms |
348 KB |
Output is correct |
32 |
Correct |
0 ms |
348 KB |
Output is correct |
33 |
Correct |
0 ms |
348 KB |
Output is correct |
34 |
Correct |
0 ms |
348 KB |
Output is correct |
35 |
Correct |
0 ms |
348 KB |
Output is correct |
36 |
Correct |
1 ms |
348 KB |
Output is correct |
37 |
Correct |
0 ms |
456 KB |
Output is correct |
38 |
Correct |
1 ms |
352 KB |
Output is correct |
39 |
Correct |
1 ms |
464 KB |
Output is correct |
40 |
Correct |
1 ms |
344 KB |
Output is correct |
41 |
Correct |
128 ms |
39140 KB |
Output is correct |
42 |
Correct |
16 ms |
2776 KB |
Output is correct |
43 |
Correct |
10 ms |
2260 KB |
Output is correct |
44 |
Correct |
39 ms |
7612 KB |
Output is correct |
45 |
Correct |
122 ms |
39396 KB |
Output is correct |
46 |
Correct |
35 ms |
7884 KB |
Output is correct |
47 |
Correct |
13 ms |
2512 KB |
Output is correct |
48 |
Correct |
123 ms |
38456 KB |
Output is correct |
49 |
Correct |
121 ms |
39360 KB |
Output is correct |
50 |
Correct |
31 ms |
4812 KB |
Output is correct |
51 |
Correct |
14 ms |
2516 KB |
Output is correct |
52 |
Correct |
126 ms |
41224 KB |
Output is correct |
53 |
Correct |
129 ms |
40136 KB |
Output is correct |
54 |
Correct |
25 ms |
4556 KB |
Output is correct |
55 |
Correct |
59 ms |
10700 KB |
Output is correct |
56 |
Correct |
34 ms |
7616 KB |
Output is correct |
57 |
Correct |
44 ms |
9172 KB |
Output is correct |
58 |
Correct |
130 ms |
39384 KB |
Output is correct |
59 |
Correct |
29 ms |
4808 KB |
Output is correct |
60 |
Correct |
40 ms |
6088 KB |
Output is correct |