Submission #699103

# Submission time Handle Problem Language Result Execution time Memory
699103 2023-02-15T15:26:39 Z mickeydesai Lasers (NOI19_lasers) C++14
100 / 100
434 ms 101360 KB
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define ii pair<int,int>
#define fi first
#define se second
#define vi vector<int>
#define ll long long
#define FORU(i,j,n) for(int i=(j);i<=(n);i++)
#define FORD(i,j,n) for(int i=(j);i>=(n);i--)
using namespace std;

const int N=5e5+5;
int L,n;
int k[N];
vi x[N];
vi l[N],r[N];
set<ii> ans;

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>L>>n;
    FORU(i,1,n)
    {
        cin>>k[i];
        x[i].resize(k[i]+2,0);
        l[i].resize(k[i]+2,0);
        r[i].resize(k[i]+2,0);
        FORU(j,1,k[i])cin>>x[i][j],l[i][j]=l[i][j-1]+x[i][j];
        FORD(j,k[i],1)r[i][j]=r[i][j+1]+x[i][j];

        FORU(j,1,k[i])
            if(l[i][j-1]+r[i][j]+x[i][j]>L)ans.insert({L-r[i][j]+1,l[i][j]});
    }
    int res=0,pre=1,cur=0;
    for(auto x:ans)
    {
        if(cur<x.fi)
        {
            res+=cur-pre+1;
            pre=x.fi;cur=x.se;
        }
        else cur=max(cur,x.se);
    }
    res+=cur-pre+1;
    cout<<res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 20 ms 35540 KB Output is correct
2 Correct 19 ms 35556 KB Output is correct
3 Correct 19 ms 35476 KB Output is correct
4 Correct 20 ms 35496 KB Output is correct
5 Correct 19 ms 35556 KB Output is correct
6 Correct 19 ms 35444 KB Output is correct
7 Correct 20 ms 35444 KB Output is correct
8 Correct 20 ms 35540 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 21 ms 35660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 35540 KB Output is correct
2 Correct 19 ms 35556 KB Output is correct
3 Correct 19 ms 35476 KB Output is correct
4 Correct 20 ms 35496 KB Output is correct
5 Correct 19 ms 35556 KB Output is correct
6 Correct 19 ms 35444 KB Output is correct
7 Correct 20 ms 35444 KB Output is correct
8 Correct 20 ms 35540 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 21 ms 35660 KB Output is correct
11 Correct 22 ms 35644 KB Output is correct
12 Correct 172 ms 89276 KB Output is correct
13 Correct 19 ms 35540 KB Output is correct
14 Correct 20 ms 35540 KB Output is correct
15 Correct 20 ms 35656 KB Output is correct
16 Correct 20 ms 35676 KB Output is correct
17 Correct 381 ms 99812 KB Output is correct
18 Correct 19 ms 35540 KB Output is correct
19 Correct 19 ms 35564 KB Output is correct
20 Correct 19 ms 35528 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 47080 KB Output is correct
2 Correct 32 ms 37816 KB Output is correct
3 Correct 29 ms 37452 KB Output is correct
4 Correct 74 ms 48512 KB Output is correct
5 Correct 42 ms 40652 KB Output is correct
6 Correct 49 ms 43328 KB Output is correct
7 Correct 20 ms 35668 KB Output is correct
8 Correct 65 ms 44748 KB Output is correct
9 Correct 56 ms 44284 KB Output is correct
10 Correct 86 ms 50640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 21 ms 35540 KB Output is correct
2 Correct 21 ms 35540 KB Output is correct
3 Correct 21 ms 35516 KB Output is correct
4 Correct 21 ms 35540 KB Output is correct
5 Correct 21 ms 35556 KB Output is correct
6 Correct 21 ms 35552 KB Output is correct
7 Correct 21 ms 35644 KB Output is correct
8 Correct 21 ms 35668 KB Output is correct
9 Correct 20 ms 35648 KB Output is correct
10 Correct 20 ms 35556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 69 ms 47080 KB Output is correct
2 Correct 32 ms 37816 KB Output is correct
3 Correct 29 ms 37452 KB Output is correct
4 Correct 74 ms 48512 KB Output is correct
5 Correct 42 ms 40652 KB Output is correct
6 Correct 49 ms 43328 KB Output is correct
7 Correct 20 ms 35668 KB Output is correct
8 Correct 65 ms 44748 KB Output is correct
9 Correct 56 ms 44284 KB Output is correct
10 Correct 86 ms 50640 KB Output is correct
11 Correct 21 ms 35540 KB Output is correct
12 Correct 21 ms 35540 KB Output is correct
13 Correct 21 ms 35516 KB Output is correct
14 Correct 21 ms 35540 KB Output is correct
15 Correct 21 ms 35556 KB Output is correct
16 Correct 21 ms 35552 KB Output is correct
17 Correct 21 ms 35644 KB Output is correct
18 Correct 21 ms 35668 KB Output is correct
19 Correct 20 ms 35648 KB Output is correct
20 Correct 20 ms 35556 KB Output is correct
21 Correct 381 ms 97284 KB Output is correct
22 Correct 50 ms 40696 KB Output is correct
23 Correct 35 ms 39192 KB Output is correct
24 Correct 82 ms 50252 KB Output is correct
25 Correct 387 ms 97152 KB Output is correct
26 Correct 84 ms 46192 KB Output is correct
27 Correct 43 ms 39788 KB Output is correct
28 Correct 381 ms 97040 KB Output is correct
29 Correct 423 ms 97356 KB Output is correct
30 Correct 67 ms 46108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 20 ms 35540 KB Output is correct
2 Correct 19 ms 35556 KB Output is correct
3 Correct 19 ms 35476 KB Output is correct
4 Correct 20 ms 35496 KB Output is correct
5 Correct 19 ms 35556 KB Output is correct
6 Correct 19 ms 35444 KB Output is correct
7 Correct 20 ms 35444 KB Output is correct
8 Correct 20 ms 35540 KB Output is correct
9 Correct 22 ms 35532 KB Output is correct
10 Correct 21 ms 35660 KB Output is correct
11 Correct 22 ms 35644 KB Output is correct
12 Correct 172 ms 89276 KB Output is correct
13 Correct 19 ms 35540 KB Output is correct
14 Correct 20 ms 35540 KB Output is correct
15 Correct 20 ms 35656 KB Output is correct
16 Correct 20 ms 35676 KB Output is correct
17 Correct 381 ms 99812 KB Output is correct
18 Correct 19 ms 35540 KB Output is correct
19 Correct 19 ms 35564 KB Output is correct
20 Correct 19 ms 35528 KB Output is correct
21 Correct 69 ms 47080 KB Output is correct
22 Correct 32 ms 37816 KB Output is correct
23 Correct 29 ms 37452 KB Output is correct
24 Correct 74 ms 48512 KB Output is correct
25 Correct 42 ms 40652 KB Output is correct
26 Correct 49 ms 43328 KB Output is correct
27 Correct 20 ms 35668 KB Output is correct
28 Correct 65 ms 44748 KB Output is correct
29 Correct 56 ms 44284 KB Output is correct
30 Correct 86 ms 50640 KB Output is correct
31 Correct 21 ms 35540 KB Output is correct
32 Correct 21 ms 35540 KB Output is correct
33 Correct 21 ms 35516 KB Output is correct
34 Correct 21 ms 35540 KB Output is correct
35 Correct 21 ms 35556 KB Output is correct
36 Correct 21 ms 35552 KB Output is correct
37 Correct 21 ms 35644 KB Output is correct
38 Correct 21 ms 35668 KB Output is correct
39 Correct 20 ms 35648 KB Output is correct
40 Correct 20 ms 35556 KB Output is correct
41 Correct 381 ms 97284 KB Output is correct
42 Correct 50 ms 40696 KB Output is correct
43 Correct 35 ms 39192 KB Output is correct
44 Correct 82 ms 50252 KB Output is correct
45 Correct 387 ms 97152 KB Output is correct
46 Correct 84 ms 46192 KB Output is correct
47 Correct 43 ms 39788 KB Output is correct
48 Correct 381 ms 97040 KB Output is correct
49 Correct 423 ms 97356 KB Output is correct
50 Correct 67 ms 46108 KB Output is correct
51 Correct 42 ms 40572 KB Output is correct
52 Correct 394 ms 100468 KB Output is correct
53 Correct 434 ms 100368 KB Output is correct
54 Correct 61 ms 42928 KB Output is correct
55 Correct 129 ms 53284 KB Output is correct
56 Correct 81 ms 48508 KB Output is correct
57 Correct 91 ms 47788 KB Output is correct
58 Correct 413 ms 101360 KB Output is correct
59 Correct 78 ms 44620 KB Output is correct
60 Correct 95 ms 47516 KB Output is correct