Submission #742925

# Submission time Handle Problem Language Result Execution time Memory
742925 2023-05-17T06:11:38 Z vjudge1 Lasers (NOI19_lasers) C++17
100 / 100
192 ms 58448 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 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 152 ms 58448 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 185 ms 55052 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 6312 KB Output is correct
2 Correct 10 ms 1388 KB Output is correct
3 Correct 8 ms 1240 KB Output is correct
4 Correct 50 ms 6332 KB Output is correct
5 Correct 18 ms 3400 KB Output is correct
6 Correct 26 ms 3868 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 29 ms 4160 KB Output is correct
9 Correct 23 ms 5564 KB Output is correct
10 Correct 62 ms 6580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 6312 KB Output is correct
2 Correct 10 ms 1388 KB Output is correct
3 Correct 8 ms 1240 KB Output is correct
4 Correct 50 ms 6332 KB Output is correct
5 Correct 18 ms 3400 KB Output is correct
6 Correct 26 ms 3868 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 29 ms 4160 KB Output is correct
9 Correct 23 ms 5564 KB Output is correct
10 Correct 62 ms 6580 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 324 KB Output is correct
13 Correct 1 ms 316 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 320 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 166 ms 53472 KB Output is correct
22 Correct 23 ms 2608 KB Output is correct
23 Correct 16 ms 2056 KB Output is correct
24 Correct 51 ms 7444 KB Output is correct
25 Correct 166 ms 53396 KB Output is correct
26 Correct 43 ms 6844 KB Output is correct
27 Correct 18 ms 2468 KB Output is correct
28 Correct 152 ms 53312 KB Output is correct
29 Correct 192 ms 53504 KB Output is correct
30 Correct 36 ms 4752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 320 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 152 ms 58448 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 324 KB Output is correct
17 Correct 185 ms 55052 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 320 KB Output is correct
20 Correct 0 ms 320 KB Output is correct
21 Correct 43 ms 6312 KB Output is correct
22 Correct 10 ms 1388 KB Output is correct
23 Correct 8 ms 1240 KB Output is correct
24 Correct 50 ms 6332 KB Output is correct
25 Correct 18 ms 3400 KB Output is correct
26 Correct 26 ms 3868 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 29 ms 4160 KB Output is correct
29 Correct 23 ms 5564 KB Output is correct
30 Correct 62 ms 6580 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 324 KB Output is correct
33 Correct 1 ms 316 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 320 KB Output is correct
36 Correct 1 ms 340 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 324 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 166 ms 53472 KB Output is correct
42 Correct 23 ms 2608 KB Output is correct
43 Correct 16 ms 2056 KB Output is correct
44 Correct 51 ms 7444 KB Output is correct
45 Correct 166 ms 53396 KB Output is correct
46 Correct 43 ms 6844 KB Output is correct
47 Correct 18 ms 2468 KB Output is correct
48 Correct 152 ms 53312 KB Output is correct
49 Correct 192 ms 53504 KB Output is correct
50 Correct 36 ms 4752 KB Output is correct
51 Correct 17 ms 2616 KB Output is correct
52 Correct 177 ms 54408 KB Output is correct
53 Correct 187 ms 54404 KB Output is correct
54 Correct 34 ms 4608 KB Output is correct
55 Correct 88 ms 9636 KB Output is correct
56 Correct 41 ms 7356 KB Output is correct
57 Correct 52 ms 7868 KB Output is correct
58 Correct 185 ms 54840 KB Output is correct
59 Correct 38 ms 4788 KB Output is correct
60 Correct 66 ms 5948 KB Output is correct