Submission #1007974

# Submission time Handle Problem Language Result Execution time Memory
1007974 2024-06-26T04:09:12 Z Luvidi Lasers (NOI19_lasers) C++17
100 / 100
94 ms 32972 KB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pll pair<ll, ll>
#define pii pair<int, int>
#define fs first
#define sc second
#define pb push_back

void solve() {
    int l,r;
    cin>>l>>r;
    vector<int> a[r];
    for (int i=0;i<r;i++){
        int x;
        cin>>x;
        while(x--){
            int y;
            cin>>y;
            a[i].pb(y);
        }
    }
    vector<pii> seg;
    for (int i=0;i<r;i++){
        int s=a[i].size();
        int pre[s],suf[s];
        pre[0]=a[i][0];
        for (int j=1;j<s;j++)pre[j]=pre[j-1]+a[i][j];
        suf[s-1]=a[i][s-1];
        for (int j=s-2;j>=0;j--)suf[j]=suf[j+1]+a[i][j];
        for (int j=0;j<s;j++){
            int le=l-suf[j]+1, ri=pre[j];
            if(le<=ri)seg.pb({le,ri});
        }
    }
    sort(seg.begin(),seg.end());
    int ans=0,le=0,ri=-1;
    for (int i=0;i<seg.size();i++){
        if(seg[i].fs>ri){
            ans+=ri-le+1;
            le=seg[i].fs;
        }
        ri=max(ri,seg[i].sc);
    }
    cout<<ans+ri-le+1;
}

int main() {   
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}

Compilation message

lasers.cpp: In function 'void solve()':
lasers.cpp:39:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     for (int i=0;i<seg.size();i++){
      |                  ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 82 ms 32972 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 90 ms 29684 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 4952 KB Output is correct
2 Correct 4 ms 1504 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 27 ms 4964 KB Output is correct
5 Correct 11 ms 3536 KB Output is correct
6 Correct 20 ms 5328 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 22 ms 5340 KB Output is correct
9 Correct 13 ms 4308 KB Output is correct
10 Correct 27 ms 5344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 4952 KB Output is correct
2 Correct 4 ms 1504 KB Output is correct
3 Correct 5 ms 1372 KB Output is correct
4 Correct 27 ms 4964 KB Output is correct
5 Correct 11 ms 3536 KB Output is correct
6 Correct 20 ms 5328 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 22 ms 5340 KB Output is correct
9 Correct 13 ms 4308 KB Output is correct
10 Correct 27 ms 5344 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 87 ms 29568 KB Output is correct
22 Correct 11 ms 1752 KB Output is correct
23 Correct 7 ms 1496 KB Output is correct
24 Correct 28 ms 5752 KB Output is correct
25 Correct 89 ms 29640 KB Output is correct
26 Correct 23 ms 4048 KB Output is correct
27 Correct 9 ms 1496 KB Output is correct
28 Correct 91 ms 29644 KB Output is correct
29 Correct 91 ms 29808 KB Output is correct
30 Correct 21 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 82 ms 32972 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 90 ms 29684 KB Output is correct
18 Correct 0 ms 344 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 24 ms 4952 KB Output is correct
22 Correct 4 ms 1504 KB Output is correct
23 Correct 5 ms 1372 KB Output is correct
24 Correct 27 ms 4964 KB Output is correct
25 Correct 11 ms 3536 KB Output is correct
26 Correct 20 ms 5328 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 22 ms 5340 KB Output is correct
29 Correct 13 ms 4308 KB Output is correct
30 Correct 27 ms 5344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 87 ms 29568 KB Output is correct
42 Correct 11 ms 1752 KB Output is correct
43 Correct 7 ms 1496 KB Output is correct
44 Correct 28 ms 5752 KB Output is correct
45 Correct 89 ms 29640 KB Output is correct
46 Correct 23 ms 4048 KB Output is correct
47 Correct 9 ms 1496 KB Output is correct
48 Correct 91 ms 29644 KB Output is correct
49 Correct 91 ms 29808 KB Output is correct
50 Correct 21 ms 3924 KB Output is correct
51 Correct 9 ms 1752 KB Output is correct
52 Correct 92 ms 29356 KB Output is correct
53 Correct 91 ms 29572 KB Output is correct
54 Correct 17 ms 2504 KB Output is correct
55 Correct 40 ms 5060 KB Output is correct
56 Correct 25 ms 4824 KB Output is correct
57 Correct 27 ms 4304 KB Output is correct
58 Correct 94 ms 29600 KB Output is correct
59 Correct 24 ms 2772 KB Output is correct
60 Correct 33 ms 3404 KB Output is correct