Submission #545650

# Submission time Handle Problem Language Result Execution time Memory
545650 2022-04-05T05:33:36 Z balbit Lasers (NOI19_lasers) C++14
100 / 100
172 ms 13836 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define f first
#define s second
#define pii pair<int, int>

#define MX(a,b) a=max(a,b)
#define MN(a,b) a=min(a,b)
#define SZ(x) (int)(x).size()
#define ALL(x) (x).begin(), (x).end()

#define REP(i,n) for (int i = 0; i<n; ++i)
#define REP1(i,n) for (int i = 1; i<=n; ++i)
#define pb push_back

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<": "<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do( T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do( T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif // BALBIT

const int maxn = 3e5+5;


signed main(){
    ios::sync_with_stdio(0), cin.tie(0);
    bug(1,2);

    int L,n; cin>>L>>n;

    vector<pii> seg;

    REP(rnd,n) {
        int k; cin>>k;
        vector<int> a(k);
        vector<int> ps(k+1);
        int tot = 0;
        REP(i,k) {
            cin>>a[i]; tot += a[i];
            ps[i+1] = ps[i] + a[i];
        }
        REP(i,k) {
            int l = L - (tot - ps[i]) + 1, r = ps[i+1];
            if (l <= r) {
                seg.pb({l,1}); seg.pb({r+1, -1}); bug(l,r);
            }
        }
    }

    sort(ALL(seg));
    int prv = 1;
    int cnt = 0;
    int re = 0;
    for (pii p : seg) {
        if (cnt) {
            re += p.f - prv;
        }
        cnt += p.s;
        prv = p.f;
    }
    cout<<re<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 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 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 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 132 ms 13836 KB Output is correct
13 Correct 0 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 172 ms 9380 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 45 ms 6152 KB Output is correct
2 Correct 7 ms 1644 KB Output is correct
3 Correct 10 ms 1336 KB Output is correct
4 Correct 54 ms 6584 KB Output is correct
5 Correct 21 ms 3968 KB Output is correct
6 Correct 32 ms 3792 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 31 ms 4276 KB Output is correct
9 Correct 26 ms 5304 KB Output is correct
10 Correct 48 ms 6640 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 320 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 328 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 45 ms 6152 KB Output is correct
2 Correct 7 ms 1644 KB Output is correct
3 Correct 10 ms 1336 KB Output is correct
4 Correct 54 ms 6584 KB Output is correct
5 Correct 21 ms 3968 KB Output is correct
6 Correct 32 ms 3792 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 31 ms 4276 KB Output is correct
9 Correct 26 ms 5304 KB Output is correct
10 Correct 48 ms 6640 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 320 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 1 ms 340 KB Output is correct
21 Correct 142 ms 8640 KB Output is correct
22 Correct 19 ms 2032 KB Output is correct
23 Correct 13 ms 1892 KB Output is correct
24 Correct 59 ms 6104 KB Output is correct
25 Correct 137 ms 8504 KB Output is correct
26 Correct 43 ms 5708 KB Output is correct
27 Correct 17 ms 1916 KB Output is correct
28 Correct 138 ms 8516 KB Output is correct
29 Correct 145 ms 8544 KB Output is correct
30 Correct 40 ms 3540 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 324 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 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 132 ms 13836 KB Output is correct
13 Correct 0 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 172 ms 9380 KB Output is correct
18 Correct 1 ms 324 KB Output is correct
19 Correct 0 ms 212 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 45 ms 6152 KB Output is correct
22 Correct 7 ms 1644 KB Output is correct
23 Correct 10 ms 1336 KB Output is correct
24 Correct 54 ms 6584 KB Output is correct
25 Correct 21 ms 3968 KB Output is correct
26 Correct 32 ms 3792 KB Output is correct
27 Correct 1 ms 460 KB Output is correct
28 Correct 31 ms 4276 KB Output is correct
29 Correct 26 ms 5304 KB Output is correct
30 Correct 48 ms 6640 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 320 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 1 ms 324 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 1 ms 340 KB Output is correct
38 Correct 1 ms 328 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 142 ms 8640 KB Output is correct
42 Correct 19 ms 2032 KB Output is correct
43 Correct 13 ms 1892 KB Output is correct
44 Correct 59 ms 6104 KB Output is correct
45 Correct 137 ms 8504 KB Output is correct
46 Correct 43 ms 5708 KB Output is correct
47 Correct 17 ms 1916 KB Output is correct
48 Correct 138 ms 8516 KB Output is correct
49 Correct 145 ms 8544 KB Output is correct
50 Correct 40 ms 3540 KB Output is correct
51 Correct 18 ms 2164 KB Output is correct
52 Correct 146 ms 9828 KB Output is correct
53 Correct 151 ms 9576 KB Output is correct
54 Correct 32 ms 3816 KB Output is correct
55 Correct 76 ms 6964 KB Output is correct
56 Correct 41 ms 6160 KB Output is correct
57 Correct 49 ms 6504 KB Output is correct
58 Correct 152 ms 9872 KB Output is correct
59 Correct 35 ms 3568 KB Output is correct
60 Correct 47 ms 4636 KB Output is correct