Submission #638624

# Submission time Handle Problem Language Result Execution time Memory
638624 2022-09-06T14:32:23 Z PoonYaPat Lasers (NOI19_lasers) C++14
100 / 100
123 ms 9996 KB
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n,l;
int a[500001],sum1,sum2;
vector<pii> v,vv;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>l>>n;
    for (int i=0; i<n; ++i) {
        int x; cin>>x;
        sum1=0; sum2=0;
        for (int j=1; j<=x; ++j) cin>>a[j], sum2+=a[j];
        for (int j=0; j<=x; ++j) {
            sum1+=a[j]; sum2-=a[j];
            vv.push_back(pii(sum1+1,l-sum2));
        }
        for (int j=1; j<vv.size(); ++j) {
            if (vv[j].first-vv[j-1].second>1) {
                v.push_back(pii(vv[j-1].second+1,vv[j].first-1));
            }
        }
        vv.clear();
    }
    sort(v.begin(),v.end());
    int pre=-1,ans=0;
    for (auto s : v) {
        if (s.first>pre) {
            ans+=s.second-s.first+1;
            pre=s.second;
        } else if (pre<s.second) {
            ans+=s.second-pre;
            pre=s.second;
        }
    }
    cout<<ans;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:20:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         for (int j=1; j<vv.size(); ++j) {
      |                       ~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 92 ms 9996 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 123 ms 7812 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 5964 KB Output is correct
2 Correct 7 ms 1684 KB Output is correct
3 Correct 8 ms 1372 KB Output is correct
4 Correct 36 ms 6092 KB Output is correct
5 Correct 21 ms 3400 KB Output is correct
6 Correct 31 ms 6676 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 33 ms 7232 KB Output is correct
9 Correct 18 ms 3980 KB Output is correct
10 Correct 49 ms 6288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 320 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 33 ms 5964 KB Output is correct
2 Correct 7 ms 1684 KB Output is correct
3 Correct 8 ms 1372 KB Output is correct
4 Correct 36 ms 6092 KB Output is correct
5 Correct 21 ms 3400 KB Output is correct
6 Correct 31 ms 6676 KB Output is correct
7 Correct 2 ms 468 KB Output is correct
8 Correct 33 ms 7232 KB Output is correct
9 Correct 18 ms 3980 KB Output is correct
10 Correct 49 ms 6288 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 1 ms 320 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 340 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 104 ms 6736 KB Output is correct
22 Correct 15 ms 1596 KB Output is correct
23 Correct 10 ms 1560 KB Output is correct
24 Correct 41 ms 4624 KB Output is correct
25 Correct 102 ms 6652 KB Output is correct
26 Correct 32 ms 3776 KB Output is correct
27 Correct 14 ms 1440 KB Output is correct
28 Correct 97 ms 6592 KB Output is correct
29 Correct 102 ms 6792 KB Output is correct
30 Correct 31 ms 3160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 328 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 328 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 92 ms 9996 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 123 ms 7812 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 33 ms 5964 KB Output is correct
22 Correct 7 ms 1684 KB Output is correct
23 Correct 8 ms 1372 KB Output is correct
24 Correct 36 ms 6092 KB Output is correct
25 Correct 21 ms 3400 KB Output is correct
26 Correct 31 ms 6676 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 33 ms 7232 KB Output is correct
29 Correct 18 ms 3980 KB Output is correct
30 Correct 49 ms 6288 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 328 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 0 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 320 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 212 KB Output is correct
41 Correct 104 ms 6736 KB Output is correct
42 Correct 15 ms 1596 KB Output is correct
43 Correct 10 ms 1560 KB Output is correct
44 Correct 41 ms 4624 KB Output is correct
45 Correct 102 ms 6652 KB Output is correct
46 Correct 32 ms 3776 KB Output is correct
47 Correct 14 ms 1440 KB Output is correct
48 Correct 97 ms 6592 KB Output is correct
49 Correct 102 ms 6792 KB Output is correct
50 Correct 31 ms 3160 KB Output is correct
51 Correct 14 ms 1876 KB Output is correct
52 Correct 102 ms 8000 KB Output is correct
53 Correct 106 ms 7760 KB Output is correct
54 Correct 26 ms 2836 KB Output is correct
55 Correct 64 ms 5312 KB Output is correct
56 Correct 34 ms 4820 KB Output is correct
57 Correct 40 ms 4548 KB Output is correct
58 Correct 106 ms 8000 KB Output is correct
59 Correct 33 ms 2620 KB Output is correct
60 Correct 39 ms 3652 KB Output is correct