답안 #853566

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
853566 2023-09-24T16:13:35 Z annabeth9680 Lasers (NOI19_lasers) C++17
100 / 100
87 ms 10172 KB
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int L,R; cin >> L >> R;
    vector<pair<int,int>> blocks;
    for(int i = 0;i<R;++i){
        int X; cin >> X;
        vector<int> W(X+1);
        int l = 0, r = L;
        for(int j = 1;j<=X;++j){
            cin >> W[j];
            l += W[j];
        }
        l -= W[X];
        for(int j = X;j>=1;--j){
            int l1 = l, l2 = r-W[j], r1 = r, r2 = l+W[j];
            if(max(l1,l2) < min(r1,r2)){
                blocks.push_back({max(l1,l2),min(r1,r2)});
            }
            if(j != 1) l -= W[j-1];
            r -= W[j];
        }

    }
    sort(blocks.begin(),blocks.end());
    int l = 0, r = 0, ans = 0;
    for(int i = 0;i<blocks.size();++i){
        if(blocks[i].first > r){
            ans += r-l;
            l = r = blocks[i].first;
        }
        r = max(r,blocks[i].second);
    }
    ans += r-l;
    cout << ans << "\n";
    return 0;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:28:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i = 0;i<blocks.size();++i){
      |                   ~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 74 ms 10172 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 85 ms 7876 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3664 KB Output is correct
2 Correct 5 ms 1112 KB Output is correct
3 Correct 5 ms 908 KB Output is correct
4 Correct 28 ms 3796 KB Output is correct
5 Correct 10 ms 2512 KB Output is correct
6 Correct 18 ms 2648 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 22 ms 2988 KB Output is correct
9 Correct 15 ms 2896 KB Output is correct
10 Correct 26 ms 3976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 3664 KB Output is correct
2 Correct 5 ms 1112 KB Output is correct
3 Correct 5 ms 908 KB Output is correct
4 Correct 28 ms 3796 KB Output is correct
5 Correct 10 ms 2512 KB Output is correct
6 Correct 18 ms 2648 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 22 ms 2988 KB Output is correct
9 Correct 15 ms 2896 KB Output is correct
10 Correct 26 ms 3976 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 344 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 82 ms 6596 KB Output is correct
22 Correct 12 ms 1520 KB Output is correct
23 Correct 7 ms 1232 KB Output is correct
24 Correct 29 ms 3836 KB Output is correct
25 Correct 86 ms 6604 KB Output is correct
26 Correct 24 ms 3800 KB Output is correct
27 Correct 10 ms 1524 KB Output is correct
28 Correct 79 ms 6596 KB Output is correct
29 Correct 80 ms 6604 KB Output is correct
30 Correct 22 ms 2584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 74 ms 10172 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 85 ms 7876 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 KB Output is correct
21 Correct 24 ms 3664 KB Output is correct
22 Correct 5 ms 1112 KB Output is correct
23 Correct 5 ms 908 KB Output is correct
24 Correct 28 ms 3796 KB Output is correct
25 Correct 10 ms 2512 KB Output is correct
26 Correct 18 ms 2648 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 22 ms 2988 KB Output is correct
29 Correct 15 ms 2896 KB Output is correct
30 Correct 26 ms 3976 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
37 Correct 1 ms 344 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 82 ms 6596 KB Output is correct
42 Correct 12 ms 1520 KB Output is correct
43 Correct 7 ms 1232 KB Output is correct
44 Correct 29 ms 3836 KB Output is correct
45 Correct 86 ms 6604 KB Output is correct
46 Correct 24 ms 3800 KB Output is correct
47 Correct 10 ms 1524 KB Output is correct
48 Correct 79 ms 6596 KB Output is correct
49 Correct 80 ms 6604 KB Output is correct
50 Correct 22 ms 2584 KB Output is correct
51 Correct 11 ms 1744 KB Output is correct
52 Correct 85 ms 7972 KB Output is correct
53 Correct 85 ms 7940 KB Output is correct
54 Correct 19 ms 3052 KB Output is correct
55 Correct 44 ms 5328 KB Output is correct
56 Correct 26 ms 3980 KB Output is correct
57 Correct 30 ms 4564 KB Output is correct
58 Correct 87 ms 8132 KB Output is correct
59 Correct 22 ms 2792 KB Output is correct
60 Correct 30 ms 3812 KB Output is correct