Submission #477237

# Submission time Handle Problem Language Result Execution time Memory
477237 2021-10-01T11:12:12 Z niloyroot Lasers (NOI19_lasers) C++14
100 / 100
187 ms 45032 KB
#include <bits/stdc++.h>
using namespace std;
#define forp(i,a,b) for(int i=a;i<=b;i++)
#define ll long long
#define newl '\n'

void solve(){
    ll l,r; cin>>l>>r;
    vector<ll> R[r+1];
    ll x,u,s;
    ll sum[r+1];
    forp(i,1,r){
        cin>>x; s=0;
        forp(j,1,x){
            cin>>u;
            s+=u;
            R[i].push_back(u);
        }
        sum[i]=s;
    }
    ll s1,s2;
    vector<pair<ll,ll>> v;
    forp(i,1,r){
        s1=0; s2=sum[i];
        for(auto e:R[i]){
            s2-=e;
            if(l-s1-s2<2*e){
                v.push_back({l-(s2+e)+1,s1+e});
            }
            s1+=e;
        }
    }
    sort(v.begin(), v.end());
    v.push_back({-1,-1});
    ll mx=0,ans=0;
    forp(i,0,v.size()-1){
        if(v[i].first!=v[i+1].first){
            if(v[i].first>mx){
                ans+=v[i].second-v[i].first+1;
                mx=v[i].second;
            } else if(v[i].second>mx){
                ans+=(v[i].second-mx);
                mx=v[i].second;
            }
        }
    }
    cout<<ans<<newl;
}

int main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    solve();
}

Compilation message

lasers.cpp: In function 'void solve()':
lasers.cpp:3:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    3 | #define forp(i,a,b) for(int i=a;i<=b;i++)
......
   36 |     forp(i,0,v.size()-1){
      |          ~~~~~~~~~~~~~~           
lasers.cpp:36:5: note: in expansion of macro 'forp'
   36 |     forp(i,0,v.size()-1){
      |     ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 154 ms 45032 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 187 ms 41452 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7504 KB Output is correct
2 Correct 7 ms 1740 KB Output is correct
3 Correct 8 ms 1748 KB Output is correct
4 Correct 44 ms 7492 KB Output is correct
5 Correct 19 ms 4772 KB Output is correct
6 Correct 32 ms 5988 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 40 ms 7104 KB Output is correct
9 Correct 22 ms 7112 KB Output is correct
10 Correct 48 ms 7908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 312 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 7504 KB Output is correct
2 Correct 7 ms 1740 KB Output is correct
3 Correct 8 ms 1748 KB Output is correct
4 Correct 44 ms 7492 KB Output is correct
5 Correct 19 ms 4772 KB Output is correct
6 Correct 32 ms 5988 KB Output is correct
7 Correct 1 ms 464 KB Output is correct
8 Correct 40 ms 7104 KB Output is correct
9 Correct 22 ms 7112 KB Output is correct
10 Correct 48 ms 7908 KB Output is correct
11 Correct 1 ms 312 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 208 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 147 ms 39920 KB Output is correct
22 Correct 27 ms 3528 KB Output is correct
23 Correct 15 ms 2720 KB Output is correct
24 Correct 59 ms 10576 KB Output is correct
25 Correct 135 ms 39936 KB Output is correct
26 Correct 38 ms 8756 KB Output is correct
27 Correct 14 ms 3148 KB Output is correct
28 Correct 150 ms 39772 KB Output is correct
29 Correct 145 ms 39864 KB Output is correct
30 Correct 36 ms 7112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 0 ms 208 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 0 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 0 ms 208 KB Output is correct
10 Correct 0 ms 208 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 154 ms 45032 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 300 KB Output is correct
17 Correct 187 ms 41452 KB Output is correct
18 Correct 0 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 208 KB Output is correct
21 Correct 36 ms 7504 KB Output is correct
22 Correct 7 ms 1740 KB Output is correct
23 Correct 8 ms 1748 KB Output is correct
24 Correct 44 ms 7492 KB Output is correct
25 Correct 19 ms 4772 KB Output is correct
26 Correct 32 ms 5988 KB Output is correct
27 Correct 1 ms 464 KB Output is correct
28 Correct 40 ms 7104 KB Output is correct
29 Correct 22 ms 7112 KB Output is correct
30 Correct 48 ms 7908 KB Output is correct
31 Correct 1 ms 312 KB Output is correct
32 Correct 0 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 208 KB Output is correct
35 Correct 1 ms 208 KB Output is correct
36 Correct 1 ms 336 KB Output is correct
37 Correct 1 ms 336 KB Output is correct
38 Correct 1 ms 336 KB Output is correct
39 Correct 1 ms 336 KB Output is correct
40 Correct 1 ms 336 KB Output is correct
41 Correct 147 ms 39920 KB Output is correct
42 Correct 27 ms 3528 KB Output is correct
43 Correct 15 ms 2720 KB Output is correct
44 Correct 59 ms 10576 KB Output is correct
45 Correct 135 ms 39936 KB Output is correct
46 Correct 38 ms 8756 KB Output is correct
47 Correct 14 ms 3148 KB Output is correct
48 Correct 150 ms 39772 KB Output is correct
49 Correct 145 ms 39864 KB Output is correct
50 Correct 36 ms 7112 KB Output is correct
51 Correct 16 ms 3172 KB Output is correct
52 Correct 145 ms 41016 KB Output is correct
53 Correct 150 ms 40924 KB Output is correct
54 Correct 30 ms 5996 KB Output is correct
55 Correct 63 ms 12708 KB Output is correct
56 Correct 45 ms 9656 KB Output is correct
57 Correct 50 ms 9952 KB Output is correct
58 Correct 139 ms 41160 KB Output is correct
59 Correct 45 ms 6280 KB Output is correct
60 Correct 49 ms 8140 KB Output is correct