Submission #743075

# Submission time Handle Problem Language Result Execution time Memory
743075 2023-05-17T07:45:42 Z Sainen420 Lasers (NOI19_lasers) C++17
100 / 100
202 ms 9952 KB
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int,int>;

int l,r,in,n,ans=0;
int qs[500005]={};
vector<pi> ep;

int main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> l >> r;
    qs[0]=0;
    for(int i=0;i<r;i++){
        cin >> n;
        for(int j=1;j<=n;j++){
            cin >> qs[j];
            qs[j]+=qs[j-1];
        }
        //qs[n+1]=qs[n];
        for(int j=1;j<=n;j++){
            //gen ep
            int sp=qs[j-1],sn=qs[n]-qs[j],val=qs[j]-qs[j-1];
            int L=val,M=l-sn-sp;
            //cout << '=' << L << ' ' << M << endl;
            if(M-L+1 > L)continue;
            ep.push_back({M-L+1+sp,1});
            ep.push_back({L+1+sp,-1});
        }
    }
    sort(ep.begin(),ep.end());
    ep.push_back({l,-9999});
    int block=0;
    for(int i=0,j=ep.size()-1;i<j;i++){
        auto[indx,v]=ep[i];
        //cout << indx << ' ' << v << ' ' << endl;
        block+=v;
        if(block>=1 && (ep[i+1]).first > indx){
            ans+=((ep[i+1]).first - indx);
        }
    }
    cout << ans;
    return 0;
}
/*
11 3
2 2 3
1 7
2 4 1
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 328 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 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 280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 328 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 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 105 ms 9428 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 2 ms 340 KB Output is correct
17 Correct 143 ms 5216 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 5780 KB Output is correct
2 Correct 12 ms 1368 KB Output is correct
3 Correct 10 ms 1112 KB Output is correct
4 Correct 61 ms 5900 KB Output is correct
5 Correct 30 ms 3404 KB Output is correct
6 Correct 31 ms 3536 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 35 ms 3272 KB Output is correct
9 Correct 29 ms 5300 KB Output is correct
10 Correct 77 ms 5956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 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 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 332 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 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 50 ms 5780 KB Output is correct
2 Correct 12 ms 1368 KB Output is correct
3 Correct 10 ms 1112 KB Output is correct
4 Correct 61 ms 5900 KB Output is correct
5 Correct 30 ms 3404 KB Output is correct
6 Correct 31 ms 3536 KB Output is correct
7 Correct 1 ms 468 KB Output is correct
8 Correct 35 ms 3272 KB Output is correct
9 Correct 29 ms 5300 KB Output is correct
10 Correct 77 ms 5956 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 212 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 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 332 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 340 KB Output is correct
21 Correct 138 ms 8600 KB Output is correct
22 Correct 28 ms 2004 KB Output is correct
23 Correct 15 ms 1876 KB Output is correct
24 Correct 49 ms 5828 KB Output is correct
25 Correct 119 ms 8552 KB Output is correct
26 Correct 73 ms 5668 KB Output is correct
27 Correct 29 ms 1944 KB Output is correct
28 Correct 202 ms 8564 KB Output is correct
29 Correct 126 ms 8632 KB Output is correct
30 Correct 45 ms 3412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 328 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 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 105 ms 9428 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 2 ms 340 KB Output is correct
17 Correct 143 ms 5216 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 328 KB Output is correct
21 Correct 50 ms 5780 KB Output is correct
22 Correct 12 ms 1368 KB Output is correct
23 Correct 10 ms 1112 KB Output is correct
24 Correct 61 ms 5900 KB Output is correct
25 Correct 30 ms 3404 KB Output is correct
26 Correct 31 ms 3536 KB Output is correct
27 Correct 1 ms 468 KB Output is correct
28 Correct 35 ms 3272 KB Output is correct
29 Correct 29 ms 5300 KB Output is correct
30 Correct 77 ms 5956 KB Output is correct
31 Correct 1 ms 340 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 332 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 340 KB Output is correct
41 Correct 138 ms 8600 KB Output is correct
42 Correct 28 ms 2004 KB Output is correct
43 Correct 15 ms 1876 KB Output is correct
44 Correct 49 ms 5828 KB Output is correct
45 Correct 119 ms 8552 KB Output is correct
46 Correct 73 ms 5668 KB Output is correct
47 Correct 29 ms 1944 KB Output is correct
48 Correct 202 ms 8564 KB Output is correct
49 Correct 126 ms 8632 KB Output is correct
50 Correct 45 ms 3412 KB Output is correct
51 Correct 19 ms 2256 KB Output is correct
52 Correct 164 ms 9772 KB Output is correct
53 Correct 157 ms 9596 KB Output is correct
54 Correct 31 ms 3920 KB Output is correct
55 Correct 76 ms 6896 KB Output is correct
56 Correct 50 ms 6232 KB Output is correct
57 Correct 67 ms 6524 KB Output is correct
58 Correct 149 ms 9952 KB Output is correct
59 Correct 37 ms 3548 KB Output is correct
60 Correct 50 ms 4656 KB Output is correct