Submission #227604

# Submission time Handle Problem Language Result Execution time Memory
227604 2020-04-28T04:30:09 Z Autoratch Lasers (NOI19_lasers) C++14
100 / 100
146 ms 10080 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 5e5 + 1;

int m,n;
vector<pair<int,int> > a;
int tmp[N];

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

    cin >> m >> n;
    for(int i = 1;i <= n;i++)
    {
        int am,sum = 0;
        cin >> am;
        for(int j = 0;j < am;j++){ int x; cin >> x; sum+=x; tmp[j] = x; }
        int ll = 0,rr = sum;
        for(int j = 0;j < am;j++)
        {
            rr-=tmp[j];
            int l = ll+tmp[j],r = m-rr-tmp[j]+1;
            if(r<=l) a.push_back({r,l});
            ll+=tmp[j];
        }
    }
    sort(a.begin(),a.end());
    int now = 0,ans = 0;
    for(auto [x,y] : a) 
    {
        if(now<x) now = y,ans+=y-x+1;
        else if(y>now) ans+=y-now,now = y;
    }
    cout << ans;
}

Compilation message

lasers.cpp: In function 'int main()':
lasers.cpp:31:14: warning: decomposition declaration only available with -std=c++1z or -std=gnu++1z
     for(auto [x,y] : a) 
              ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 4 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 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 4 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 129 ms 10080 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 145 ms 8016 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 39 ms 3184 KB Output is correct
2 Correct 11 ms 1152 KB Output is correct
3 Correct 12 ms 1024 KB Output is correct
4 Correct 47 ms 3824 KB Output is correct
5 Correct 21 ms 2300 KB Output is correct
6 Correct 35 ms 3192 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 38 ms 2932 KB Output is correct
9 Correct 26 ms 3320 KB Output is correct
10 Correct 44 ms 3952 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 4 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 39 ms 3184 KB Output is correct
2 Correct 11 ms 1152 KB Output is correct
3 Correct 12 ms 1024 KB Output is correct
4 Correct 47 ms 3824 KB Output is correct
5 Correct 21 ms 2300 KB Output is correct
6 Correct 35 ms 3192 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 38 ms 2932 KB Output is correct
9 Correct 26 ms 3320 KB Output is correct
10 Correct 44 ms 3952 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 4 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 132 ms 6760 KB Output is correct
22 Correct 24 ms 1660 KB Output is correct
23 Correct 15 ms 1408 KB Output is correct
24 Correct 52 ms 3952 KB Output is correct
25 Correct 130 ms 6760 KB Output is correct
26 Correct 41 ms 3704 KB Output is correct
27 Correct 20 ms 1536 KB Output is correct
28 Correct 135 ms 6892 KB Output is correct
29 Correct 136 ms 6760 KB Output is correct
30 Correct 39 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 4 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 129 ms 10080 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 145 ms 8016 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 5 ms 384 KB Output is correct
20 Correct 4 ms 384 KB Output is correct
21 Correct 39 ms 3184 KB Output is correct
22 Correct 11 ms 1152 KB Output is correct
23 Correct 12 ms 1024 KB Output is correct
24 Correct 47 ms 3824 KB Output is correct
25 Correct 21 ms 2300 KB Output is correct
26 Correct 35 ms 3192 KB Output is correct
27 Correct 5 ms 384 KB Output is correct
28 Correct 38 ms 2932 KB Output is correct
29 Correct 26 ms 3320 KB Output is correct
30 Correct 44 ms 3952 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 4 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 132 ms 6760 KB Output is correct
42 Correct 24 ms 1660 KB Output is correct
43 Correct 15 ms 1408 KB Output is correct
44 Correct 52 ms 3952 KB Output is correct
45 Correct 130 ms 6760 KB Output is correct
46 Correct 41 ms 3704 KB Output is correct
47 Correct 20 ms 1536 KB Output is correct
48 Correct 135 ms 6892 KB Output is correct
49 Correct 136 ms 6760 KB Output is correct
50 Correct 39 ms 2552 KB Output is correct
51 Correct 22 ms 1788 KB Output is correct
52 Correct 140 ms 8036 KB Output is correct
53 Correct 145 ms 7912 KB Output is correct
54 Correct 37 ms 2988 KB Output is correct
55 Correct 79 ms 5228 KB Output is correct
56 Correct 46 ms 4208 KB Output is correct
57 Correct 57 ms 4588 KB Output is correct
58 Correct 146 ms 8044 KB Output is correct
59 Correct 41 ms 2680 KB Output is correct
60 Correct 54 ms 3696 KB Output is correct