Submission #242845

# Submission time Handle Problem Language Result Execution time Memory
242845 2020-06-29T11:38:48 Z gs18115 Lasers (NOI19_lasers) C++14
100 / 100
181 ms 13912 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int l,r;
    cin>>l>>r;
    vector<pi>cv;
    for(int i=0;i<r;i++)
    {
        int x;
        cin>>x;
        vector<int>v(x);
        for(int&t:v)
            cin>>t;
        int sm=0,csm=0;
        for(int&t:v)
            sm+=t;
        for(int&t:v)
        {
            if(l-sm<t)
                cv.eb(l-sm+csm,1),cv.eb(csm+t,-1);
            csm+=t;
        }
    }
    sort(all(cv));
    int cur=0,csm=0;
    int ans=0;
    for(pi&t:cv)
    {
        if(csm>0)
            ans+=t.fi-cur;
        cur=t.fi;
        csm+=t.se;
    }
    cout<<ans<<endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 156 ms 13912 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 172 ms 9568 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 5636 KB Output is correct
2 Correct 13 ms 1408 KB Output is correct
3 Correct 14 ms 1204 KB Output is correct
4 Correct 65 ms 5884 KB Output is correct
5 Correct 28 ms 3444 KB Output is correct
6 Correct 39 ms 3156 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 42 ms 3412 KB Output is correct
9 Correct 32 ms 5104 KB Output is correct
10 Correct 66 ms 5928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 54 ms 5636 KB Output is correct
2 Correct 13 ms 1408 KB Output is correct
3 Correct 14 ms 1204 KB Output is correct
4 Correct 65 ms 5884 KB Output is correct
5 Correct 28 ms 3444 KB Output is correct
6 Correct 39 ms 3156 KB Output is correct
7 Correct 5 ms 512 KB Output is correct
8 Correct 42 ms 3412 KB Output is correct
9 Correct 32 ms 5104 KB Output is correct
10 Correct 66 ms 5928 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 5 ms 384 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 167 ms 8672 KB Output is correct
22 Correct 29 ms 2168 KB Output is correct
23 Correct 18 ms 1740 KB Output is correct
24 Correct 62 ms 5784 KB Output is correct
25 Correct 173 ms 8852 KB Output is correct
26 Correct 54 ms 5736 KB Output is correct
27 Correct 24 ms 2044 KB Output is correct
28 Correct 168 ms 8800 KB Output is correct
29 Correct 180 ms 8648 KB Output is correct
30 Correct 46 ms 3376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 156 ms 13912 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 5 ms 384 KB Output is correct
17 Correct 172 ms 9568 KB Output is correct
18 Correct 5 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 54 ms 5636 KB Output is correct
22 Correct 13 ms 1408 KB Output is correct
23 Correct 14 ms 1204 KB Output is correct
24 Correct 65 ms 5884 KB Output is correct
25 Correct 28 ms 3444 KB Output is correct
26 Correct 39 ms 3156 KB Output is correct
27 Correct 5 ms 512 KB Output is correct
28 Correct 42 ms 3412 KB Output is correct
29 Correct 32 ms 5104 KB Output is correct
30 Correct 66 ms 5928 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 5 ms 384 KB Output is correct
41 Correct 167 ms 8672 KB Output is correct
42 Correct 29 ms 2168 KB Output is correct
43 Correct 18 ms 1740 KB Output is correct
44 Correct 62 ms 5784 KB Output is correct
45 Correct 173 ms 8852 KB Output is correct
46 Correct 54 ms 5736 KB Output is correct
47 Correct 24 ms 2044 KB Output is correct
48 Correct 168 ms 8800 KB Output is correct
49 Correct 180 ms 8648 KB Output is correct
50 Correct 46 ms 3376 KB Output is correct
51 Correct 25 ms 2284 KB Output is correct
52 Correct 181 ms 9952 KB Output is correct
53 Correct 178 ms 9696 KB Output is correct
54 Correct 43 ms 3952 KB Output is correct
55 Correct 98 ms 7012 KB Output is correct
56 Correct 55 ms 6048 KB Output is correct
57 Correct 70 ms 6636 KB Output is correct
58 Correct 178 ms 10100 KB Output is correct
59 Correct 53 ms 3576 KB Output is correct
60 Correct 66 ms 4708 KB Output is correct