# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
290791 | 2020-09-04T12:59:13 Z | PKhing | Bigger segments (IZhO19_segments) | C++14 | 372 ms | 43516 KB |
#include<bits/stdc++.h> #define ll long long #define ii pair<ll,ll> using namespace std; ll tab[500005]; ll qs[500005]; ll dp[500005]; ll dp2[500005]; int n; int main(){ scanf("%d",&n); for(int i=1;i<=n;i++){ scanf("%lld",&tab[i]); qs[i]=tab[i]+qs[i-1]; } set<ii,greater<ii>> s; s.insert(make_pair(0,0)); for(int i=1;i<=n;i++){ auto x = s.lower_bound(make_pair(qs[i],1e9)); ll want = 2*qs[i]-qs[x->second]; dp[i] = dp[x->second]+1; queue<ii> del; for(auto i:s){ if(i.first>=want){ del.emplace(i); } else break; } while(!del.empty()){ s.erase(del.front()); del.pop(); } s.insert(make_pair(want,i)); } printf("%lld",dp[n]); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 416 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 416 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 640 KB | Output is correct |
35 | Correct | 2 ms | 640 KB | Output is correct |
36 | Correct | 2 ms | 512 KB | Output is correct |
37 | Correct | 2 ms | 512 KB | Output is correct |
38 | Correct | 1 ms | 512 KB | Output is correct |
39 | Correct | 2 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 640 KB | Output is correct |
41 | Correct | 2 ms | 640 KB | Output is correct |
42 | Correct | 3 ms | 640 KB | Output is correct |
43 | Correct | 2 ms | 640 KB | Output is correct |
44 | Correct | 2 ms | 640 KB | Output is correct |
45 | Correct | 2 ms | 640 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 416 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 640 KB | Output is correct |
35 | Correct | 2 ms | 640 KB | Output is correct |
36 | Correct | 2 ms | 512 KB | Output is correct |
37 | Correct | 2 ms | 512 KB | Output is correct |
38 | Correct | 1 ms | 512 KB | Output is correct |
39 | Correct | 2 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 640 KB | Output is correct |
41 | Correct | 2 ms | 640 KB | Output is correct |
42 | Correct | 3 ms | 640 KB | Output is correct |
43 | Correct | 2 ms | 640 KB | Output is correct |
44 | Correct | 2 ms | 640 KB | Output is correct |
45 | Correct | 2 ms | 640 KB | Output is correct |
46 | Correct | 50 ms | 8952 KB | Output is correct |
47 | Correct | 56 ms | 6968 KB | Output is correct |
48 | Correct | 56 ms | 3224 KB | Output is correct |
49 | Correct | 66 ms | 6264 KB | Output is correct |
50 | Correct | 61 ms | 8952 KB | Output is correct |
51 | Correct | 67 ms | 7672 KB | Output is correct |
52 | Correct | 32 ms | 3960 KB | Output is correct |
53 | Correct | 19 ms | 2560 KB | Output is correct |
54 | Correct | 60 ms | 7288 KB | Output is correct |
55 | Correct | 63 ms | 8312 KB | Output is correct |
56 | Correct | 57 ms | 8952 KB | Output is correct |
57 | Correct | 60 ms | 8952 KB | Output is correct |
58 | Correct | 56 ms | 8296 KB | Output is correct |
59 | Correct | 58 ms | 8968 KB | Output is correct |
60 | Correct | 59 ms | 8976 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 384 KB | Output is correct |
3 | Correct | 1 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 384 KB | Output is correct |
6 | Correct | 0 ms | 384 KB | Output is correct |
7 | Correct | 0 ms | 384 KB | Output is correct |
8 | Correct | 0 ms | 384 KB | Output is correct |
9 | Correct | 0 ms | 384 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 1 ms | 384 KB | Output is correct |
12 | Correct | 0 ms | 384 KB | Output is correct |
13 | Correct | 1 ms | 384 KB | Output is correct |
14 | Correct | 0 ms | 384 KB | Output is correct |
15 | Correct | 1 ms | 384 KB | Output is correct |
16 | Correct | 1 ms | 384 KB | Output is correct |
17 | Correct | 1 ms | 416 KB | Output is correct |
18 | Correct | 1 ms | 384 KB | Output is correct |
19 | Correct | 1 ms | 384 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 1 ms | 384 KB | Output is correct |
22 | Correct | 1 ms | 384 KB | Output is correct |
23 | Correct | 1 ms | 384 KB | Output is correct |
24 | Correct | 1 ms | 384 KB | Output is correct |
25 | Correct | 1 ms | 384 KB | Output is correct |
26 | Correct | 1 ms | 384 KB | Output is correct |
27 | Correct | 1 ms | 384 KB | Output is correct |
28 | Correct | 1 ms | 384 KB | Output is correct |
29 | Correct | 1 ms | 384 KB | Output is correct |
30 | Correct | 1 ms | 384 KB | Output is correct |
31 | Correct | 2 ms | 640 KB | Output is correct |
32 | Correct | 2 ms | 512 KB | Output is correct |
33 | Correct | 2 ms | 384 KB | Output is correct |
34 | Correct | 2 ms | 640 KB | Output is correct |
35 | Correct | 2 ms | 640 KB | Output is correct |
36 | Correct | 2 ms | 512 KB | Output is correct |
37 | Correct | 2 ms | 512 KB | Output is correct |
38 | Correct | 1 ms | 512 KB | Output is correct |
39 | Correct | 2 ms | 512 KB | Output is correct |
40 | Correct | 2 ms | 640 KB | Output is correct |
41 | Correct | 2 ms | 640 KB | Output is correct |
42 | Correct | 3 ms | 640 KB | Output is correct |
43 | Correct | 2 ms | 640 KB | Output is correct |
44 | Correct | 2 ms | 640 KB | Output is correct |
45 | Correct | 2 ms | 640 KB | Output is correct |
46 | Correct | 50 ms | 8952 KB | Output is correct |
47 | Correct | 56 ms | 6968 KB | Output is correct |
48 | Correct | 56 ms | 3224 KB | Output is correct |
49 | Correct | 66 ms | 6264 KB | Output is correct |
50 | Correct | 61 ms | 8952 KB | Output is correct |
51 | Correct | 67 ms | 7672 KB | Output is correct |
52 | Correct | 32 ms | 3960 KB | Output is correct |
53 | Correct | 19 ms | 2560 KB | Output is correct |
54 | Correct | 60 ms | 7288 KB | Output is correct |
55 | Correct | 63 ms | 8312 KB | Output is correct |
56 | Correct | 57 ms | 8952 KB | Output is correct |
57 | Correct | 60 ms | 8952 KB | Output is correct |
58 | Correct | 56 ms | 8296 KB | Output is correct |
59 | Correct | 58 ms | 8968 KB | Output is correct |
60 | Correct | 59 ms | 8976 KB | Output is correct |
61 | Correct | 268 ms | 43356 KB | Output is correct |
62 | Correct | 277 ms | 43388 KB | Output is correct |
63 | Correct | 309 ms | 34852 KB | Output is correct |
64 | Correct | 371 ms | 18424 KB | Output is correct |
65 | Correct | 333 ms | 43384 KB | Output is correct |
66 | Correct | 372 ms | 36872 KB | Output is correct |
67 | Correct | 296 ms | 29560 KB | Output is correct |
68 | Correct | 138 ms | 15096 KB | Output is correct |
69 | Correct | 333 ms | 34936 KB | Output is correct |
70 | Correct | 340 ms | 40952 KB | Output is correct |
71 | Correct | 310 ms | 43384 KB | Output is correct |
72 | Correct | 325 ms | 38008 KB | Output is correct |
73 | Correct | 322 ms | 38800 KB | Output is correct |
74 | Correct | 315 ms | 43444 KB | Output is correct |
75 | Correct | 328 ms | 43516 KB | Output is correct |