Submission #965953

# Submission time Handle Problem Language Result Execution time Memory
965953 2024-04-19T08:40:57 Z Jomnoi Lasers (NOI19_lasers) C++17
100 / 100
132 ms 44128 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;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 107 ms 44128 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 132 ms 40664 KB Output is correct
18 Correct 1 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 38 ms 6100 KB Output is correct
2 Correct 6 ms 1500 KB Output is correct
3 Correct 7 ms 1368 KB Output is correct
4 Correct 42 ms 6356 KB Output is correct
5 Correct 19 ms 3536 KB Output is correct
6 Correct 24 ms 3752 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 28 ms 4372 KB Output is correct
9 Correct 22 ms 7376 KB Output is correct
10 Correct 43 ms 7844 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 1 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 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 6100 KB Output is correct
2 Correct 6 ms 1500 KB Output is correct
3 Correct 7 ms 1368 KB Output is correct
4 Correct 42 ms 6356 KB Output is correct
5 Correct 19 ms 3536 KB Output is correct
6 Correct 24 ms 3752 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 28 ms 4372 KB Output is correct
9 Correct 22 ms 7376 KB Output is correct
10 Correct 43 ms 7844 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 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 0 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 123 ms 39816 KB Output is correct
22 Correct 18 ms 2776 KB Output is correct
23 Correct 10 ms 2256 KB Output is correct
24 Correct 40 ms 9368 KB Output is correct
25 Correct 127 ms 38340 KB Output is correct
26 Correct 38 ms 8392 KB Output is correct
27 Correct 14 ms 2516 KB Output is correct
28 Correct 120 ms 38088 KB Output is correct
29 Correct 123 ms 39408 KB Output is correct
30 Correct 29 ms 4820 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 452 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 0 ms 452 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 600 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 107 ms 44128 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 600 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 132 ms 40664 KB Output is correct
18 Correct 1 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 38 ms 6100 KB Output is correct
22 Correct 6 ms 1500 KB Output is correct
23 Correct 7 ms 1368 KB Output is correct
24 Correct 42 ms 6356 KB Output is correct
25 Correct 19 ms 3536 KB Output is correct
26 Correct 24 ms 3752 KB Output is correct
27 Correct 1 ms 604 KB Output is correct
28 Correct 28 ms 4372 KB Output is correct
29 Correct 22 ms 7376 KB Output is correct
30 Correct 43 ms 7844 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 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 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 123 ms 39816 KB Output is correct
42 Correct 18 ms 2776 KB Output is correct
43 Correct 10 ms 2256 KB Output is correct
44 Correct 40 ms 9368 KB Output is correct
45 Correct 127 ms 38340 KB Output is correct
46 Correct 38 ms 8392 KB Output is correct
47 Correct 14 ms 2516 KB Output is correct
48 Correct 120 ms 38088 KB Output is correct
49 Correct 123 ms 39408 KB Output is correct
50 Correct 29 ms 4820 KB Output is correct
51 Correct 14 ms 2548 KB Output is correct
52 Correct 130 ms 40900 KB Output is correct
53 Correct 130 ms 40136 KB Output is correct
54 Correct 25 ms 4556 KB Output is correct
55 Correct 59 ms 10732 KB Output is correct
56 Correct 43 ms 8900 KB Output is correct
57 Correct 40 ms 7884 KB Output is correct
58 Correct 130 ms 40440 KB Output is correct
59 Correct 29 ms 4732 KB Output is correct
60 Correct 40 ms 6088 KB Output is correct