# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
499850 | 2021-12-29T19:35:16 Z | reni | Bigger segments (IZhO19_segments) | C++14 | 105 ms | 16840 KB |
#include<iostream> #define endl '\n' using namespace std; long long pref[1000000], ans[1000000], sum[1000000]; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long n,i,j, ch, pr, br=0, maxr, le, ri, mid; cin>>n; for(i=1;i<=n;i++) { cin>>ch; pref[i]=pref[i-1]+ch; sum[i]=1000000000000; } ans[1]=1; for(i=1;i<=n;i++) { ans[i]=max(ans[i-1],ans[i]); sum[i]=min(sum[i],sum[i-1]+pref[i]-pref[i-1]); le=0;ri=n+1; int ind=-1; while(le<ri-1) { mid=(le+ri)/2; if(sum[i]<=pref[mid]-pref[i]){ri=mid;} else {le=mid;} } if(ri>n)continue; if(ans[ri]<=ans[i]+1) { ans[ri]=ans[i]+1; sum[ri]=min(sum[ri],pref[ri]-pref[i]); } //cout<<ans[i]<<" "<<sum[i]<<endl; } cout<<ans[n]<<endl; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 236 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 236 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 332 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 244 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 236 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 332 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 244 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 2 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 328 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 2 ms | 332 KB | Output is correct |
41 | Correct | 2 ms | 332 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 1 ms | 332 KB | Output is correct |
44 | Correct | 1 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 332 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 236 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 332 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 244 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 2 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 328 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 2 ms | 332 KB | Output is correct |
41 | Correct | 2 ms | 332 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 1 ms | 332 KB | Output is correct |
44 | Correct | 1 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 332 KB | Output is correct |
46 | Correct | 10 ms | 2636 KB | Output is correct |
47 | Correct | 12 ms | 3072 KB | Output is correct |
48 | Correct | 16 ms | 3420 KB | Output is correct |
49 | Correct | 21 ms | 3564 KB | Output is correct |
50 | Correct | 18 ms | 3532 KB | Output is correct |
51 | Correct | 17 ms | 3548 KB | Output is correct |
52 | Correct | 8 ms | 1868 KB | Output is correct |
53 | Correct | 5 ms | 1240 KB | Output is correct |
54 | Correct | 12 ms | 2876 KB | Output is correct |
55 | Correct | 16 ms | 3640 KB | Output is correct |
56 | Correct | 14 ms | 3084 KB | Output is correct |
57 | Correct | 13 ms | 3016 KB | Output is correct |
58 | Correct | 13 ms | 3104 KB | Output is correct |
59 | Correct | 15 ms | 3244 KB | Output is correct |
60 | Correct | 14 ms | 3156 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 332 KB | Output is correct |
2 | Correct | 0 ms | 332 KB | Output is correct |
3 | Correct | 0 ms | 332 KB | Output is correct |
4 | Correct | 0 ms | 332 KB | Output is correct |
5 | Correct | 0 ms | 332 KB | Output is correct |
6 | Correct | 0 ms | 332 KB | Output is correct |
7 | Correct | 0 ms | 332 KB | Output is correct |
8 | Correct | 0 ms | 332 KB | Output is correct |
9 | Correct | 0 ms | 332 KB | Output is correct |
10 | Correct | 0 ms | 332 KB | Output is correct |
11 | Correct | 0 ms | 236 KB | Output is correct |
12 | Correct | 0 ms | 332 KB | Output is correct |
13 | Correct | 0 ms | 332 KB | Output is correct |
14 | Correct | 0 ms | 332 KB | Output is correct |
15 | Correct | 0 ms | 332 KB | Output is correct |
16 | Correct | 0 ms | 332 KB | Output is correct |
17 | Correct | 1 ms | 332 KB | Output is correct |
18 | Correct | 0 ms | 332 KB | Output is correct |
19 | Correct | 1 ms | 332 KB | Output is correct |
20 | Correct | 1 ms | 332 KB | Output is correct |
21 | Correct | 1 ms | 332 KB | Output is correct |
22 | Correct | 1 ms | 332 KB | Output is correct |
23 | Correct | 1 ms | 332 KB | Output is correct |
24 | Correct | 1 ms | 332 KB | Output is correct |
25 | Correct | 1 ms | 332 KB | Output is correct |
26 | Correct | 0 ms | 332 KB | Output is correct |
27 | Correct | 0 ms | 332 KB | Output is correct |
28 | Correct | 1 ms | 332 KB | Output is correct |
29 | Correct | 0 ms | 332 KB | Output is correct |
30 | Correct | 0 ms | 244 KB | Output is correct |
31 | Correct | 1 ms | 332 KB | Output is correct |
32 | Correct | 1 ms | 332 KB | Output is correct |
33 | Correct | 1 ms | 332 KB | Output is correct |
34 | Correct | 1 ms | 332 KB | Output is correct |
35 | Correct | 2 ms | 332 KB | Output is correct |
36 | Correct | 1 ms | 332 KB | Output is correct |
37 | Correct | 1 ms | 332 KB | Output is correct |
38 | Correct | 1 ms | 328 KB | Output is correct |
39 | Correct | 1 ms | 344 KB | Output is correct |
40 | Correct | 2 ms | 332 KB | Output is correct |
41 | Correct | 2 ms | 332 KB | Output is correct |
42 | Correct | 1 ms | 332 KB | Output is correct |
43 | Correct | 1 ms | 332 KB | Output is correct |
44 | Correct | 1 ms | 332 KB | Output is correct |
45 | Correct | 1 ms | 332 KB | Output is correct |
46 | Correct | 10 ms | 2636 KB | Output is correct |
47 | Correct | 12 ms | 3072 KB | Output is correct |
48 | Correct | 16 ms | 3420 KB | Output is correct |
49 | Correct | 21 ms | 3564 KB | Output is correct |
50 | Correct | 18 ms | 3532 KB | Output is correct |
51 | Correct | 17 ms | 3548 KB | Output is correct |
52 | Correct | 8 ms | 1868 KB | Output is correct |
53 | Correct | 5 ms | 1240 KB | Output is correct |
54 | Correct | 12 ms | 2876 KB | Output is correct |
55 | Correct | 16 ms | 3640 KB | Output is correct |
56 | Correct | 14 ms | 3084 KB | Output is correct |
57 | Correct | 13 ms | 3016 KB | Output is correct |
58 | Correct | 13 ms | 3104 KB | Output is correct |
59 | Correct | 15 ms | 3244 KB | Output is correct |
60 | Correct | 14 ms | 3156 KB | Output is correct |
61 | Correct | 52 ms | 13892 KB | Output is correct |
62 | Correct | 54 ms | 13900 KB | Output is correct |
63 | Correct | 61 ms | 14332 KB | Output is correct |
64 | Correct | 82 ms | 16584 KB | Output is correct |
65 | Correct | 105 ms | 16840 KB | Output is correct |
66 | Correct | 81 ms | 16836 KB | Output is correct |
67 | Correct | 80 ms | 13580 KB | Output is correct |
68 | Correct | 32 ms | 6900 KB | Output is correct |
69 | Correct | 56 ms | 13072 KB | Output is correct |
70 | Correct | 86 ms | 16836 KB | Output is correct |
71 | Correct | 65 ms | 14032 KB | Output is correct |
72 | Correct | 66 ms | 14388 KB | Output is correct |
73 | Correct | 82 ms | 14952 KB | Output is correct |
74 | Correct | 79 ms | 15296 KB | Output is correct |
75 | Correct | 79 ms | 15364 KB | Output is correct |