Submission #467054

# Submission time Handle Problem Language Result Execution time Memory
467054 2021-08-21T13:31:28 Z mosiashvililuka Bigger segments (IZhO19_segments) C++14
100 / 100
159 ms 48200 KB
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,dp[500009],dp2[500009],f[500009],jm[500009],lef,rig,mid;
vector <long long> v[500009];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(i=1; i<=a; i++){
		cin>>f[i];jm[i]=jm[i-1]+f[i];
	}
	for(i=1; i<=a; i++){
		dp[i]=1;dp2[i]=jm[i];
		for(vector <long long>::iterator it=v[i].begin(); it!=v[i].end(); it++){
			/*if(dp[i]<dp[(*it)]+1||(dp[i]==dp[(*it)]+1&&dp2[i]>jm[i]-jm[(*it)])){
				dp[i]=dp[(*it)]+1;dp2[i]=jm[i]-jm[(*it)];
			}*/
			jj=max((*it),jj);
		}
		if(jj!=0){
			if(dp[i]<dp[jj]+1||(dp[i]==dp[jj]+1&&dp2[i]>jm[i]-jm[jj])){
				dp[i]=dp[jj]+1;dp2[i]=jm[i]-jm[jj];
			}
		}
		/*for(j=i-1; j>=1; j--){
			if(dp2[j]+jm[j]<=jm[i]){
				dp[i]=dp[j]+1;dp2[i]=jm[i]-jm[j];
				break;
			}
		}*/
		lef=0;rig=a+1;
		while(1){
			if(lef+1>=rig) break;
			mid=(lef+rig)/2;
			if(dp2[i]+jm[i]<=jm[mid]){
				rig=mid;
			}else{
				lef=mid;
			}
		}
		v[rig].push_back(i);
	}
	cout<<dp[a];
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 7 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 7 ms 11992 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 7 ms 11980 KB Output is correct
7 Correct 7 ms 11984 KB Output is correct
8 Correct 7 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 7 ms 11980 KB Output is correct
11 Correct 7 ms 11980 KB Output is correct
12 Correct 7 ms 11980 KB Output is correct
13 Correct 7 ms 12088 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 7 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 7 ms 11992 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 7 ms 11980 KB Output is correct
7 Correct 7 ms 11984 KB Output is correct
8 Correct 7 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 7 ms 11980 KB Output is correct
11 Correct 7 ms 11980 KB Output is correct
12 Correct 7 ms 11980 KB Output is correct
13 Correct 7 ms 12088 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 7 ms 12108 KB Output is correct
17 Correct 8 ms 12108 KB Output is correct
18 Correct 7 ms 12100 KB Output is correct
19 Correct 7 ms 12108 KB Output is correct
20 Correct 7 ms 12236 KB Output is correct
21 Correct 7 ms 12108 KB Output is correct
22 Correct 7 ms 12108 KB Output is correct
23 Correct 7 ms 12024 KB Output is correct
24 Correct 7 ms 12108 KB Output is correct
25 Correct 9 ms 12012 KB Output is correct
26 Correct 7 ms 12116 KB Output is correct
27 Correct 7 ms 12112 KB Output is correct
28 Correct 7 ms 12024 KB Output is correct
29 Correct 7 ms 12108 KB Output is correct
30 Correct 8 ms 12108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 7 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 7 ms 11992 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 7 ms 11980 KB Output is correct
7 Correct 7 ms 11984 KB Output is correct
8 Correct 7 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 7 ms 11980 KB Output is correct
11 Correct 7 ms 11980 KB Output is correct
12 Correct 7 ms 11980 KB Output is correct
13 Correct 7 ms 12088 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 7 ms 12108 KB Output is correct
17 Correct 8 ms 12108 KB Output is correct
18 Correct 7 ms 12100 KB Output is correct
19 Correct 7 ms 12108 KB Output is correct
20 Correct 7 ms 12236 KB Output is correct
21 Correct 7 ms 12108 KB Output is correct
22 Correct 7 ms 12108 KB Output is correct
23 Correct 7 ms 12024 KB Output is correct
24 Correct 7 ms 12108 KB Output is correct
25 Correct 9 ms 12012 KB Output is correct
26 Correct 7 ms 12116 KB Output is correct
27 Correct 7 ms 12112 KB Output is correct
28 Correct 7 ms 12024 KB Output is correct
29 Correct 7 ms 12108 KB Output is correct
30 Correct 8 ms 12108 KB Output is correct
31 Correct 8 ms 12236 KB Output is correct
32 Correct 8 ms 12236 KB Output is correct
33 Correct 9 ms 12236 KB Output is correct
34 Correct 8 ms 12236 KB Output is correct
35 Correct 8 ms 12236 KB Output is correct
36 Correct 8 ms 12236 KB Output is correct
37 Correct 8 ms 12108 KB Output is correct
38 Correct 8 ms 12108 KB Output is correct
39 Correct 8 ms 12208 KB Output is correct
40 Correct 8 ms 12236 KB Output is correct
41 Correct 8 ms 12236 KB Output is correct
42 Correct 8 ms 12236 KB Output is correct
43 Correct 8 ms 12236 KB Output is correct
44 Correct 8 ms 12236 KB Output is correct
45 Correct 10 ms 12212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 7 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 7 ms 11992 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 7 ms 11980 KB Output is correct
7 Correct 7 ms 11984 KB Output is correct
8 Correct 7 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 7 ms 11980 KB Output is correct
11 Correct 7 ms 11980 KB Output is correct
12 Correct 7 ms 11980 KB Output is correct
13 Correct 7 ms 12088 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 7 ms 12108 KB Output is correct
17 Correct 8 ms 12108 KB Output is correct
18 Correct 7 ms 12100 KB Output is correct
19 Correct 7 ms 12108 KB Output is correct
20 Correct 7 ms 12236 KB Output is correct
21 Correct 7 ms 12108 KB Output is correct
22 Correct 7 ms 12108 KB Output is correct
23 Correct 7 ms 12024 KB Output is correct
24 Correct 7 ms 12108 KB Output is correct
25 Correct 9 ms 12012 KB Output is correct
26 Correct 7 ms 12116 KB Output is correct
27 Correct 7 ms 12112 KB Output is correct
28 Correct 7 ms 12024 KB Output is correct
29 Correct 7 ms 12108 KB Output is correct
30 Correct 8 ms 12108 KB Output is correct
31 Correct 8 ms 12236 KB Output is correct
32 Correct 8 ms 12236 KB Output is correct
33 Correct 9 ms 12236 KB Output is correct
34 Correct 8 ms 12236 KB Output is correct
35 Correct 8 ms 12236 KB Output is correct
36 Correct 8 ms 12236 KB Output is correct
37 Correct 8 ms 12108 KB Output is correct
38 Correct 8 ms 12108 KB Output is correct
39 Correct 8 ms 12208 KB Output is correct
40 Correct 8 ms 12236 KB Output is correct
41 Correct 8 ms 12236 KB Output is correct
42 Correct 8 ms 12236 KB Output is correct
43 Correct 8 ms 12236 KB Output is correct
44 Correct 8 ms 12236 KB Output is correct
45 Correct 10 ms 12212 KB Output is correct
46 Correct 30 ms 16048 KB Output is correct
47 Correct 31 ms 17416 KB Output is correct
48 Correct 35 ms 17988 KB Output is correct
49 Correct 36 ms 19100 KB Output is correct
50 Correct 41 ms 19268 KB Output is correct
51 Correct 39 ms 18116 KB Output is correct
52 Correct 28 ms 15072 KB Output is correct
53 Correct 16 ms 13900 KB Output is correct
54 Correct 34 ms 17320 KB Output is correct
55 Correct 36 ms 18844 KB Output is correct
56 Correct 31 ms 18716 KB Output is correct
57 Correct 30 ms 17764 KB Output is correct
58 Correct 32 ms 18112 KB Output is correct
59 Correct 32 ms 18832 KB Output is correct
60 Correct 33 ms 18756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 11980 KB Output is correct
2 Correct 7 ms 11980 KB Output is correct
3 Correct 7 ms 11980 KB Output is correct
4 Correct 7 ms 11992 KB Output is correct
5 Correct 7 ms 11980 KB Output is correct
6 Correct 7 ms 11980 KB Output is correct
7 Correct 7 ms 11984 KB Output is correct
8 Correct 7 ms 11980 KB Output is correct
9 Correct 8 ms 11980 KB Output is correct
10 Correct 7 ms 11980 KB Output is correct
11 Correct 7 ms 11980 KB Output is correct
12 Correct 7 ms 11980 KB Output is correct
13 Correct 7 ms 12088 KB Output is correct
14 Correct 9 ms 11980 KB Output is correct
15 Correct 8 ms 11980 KB Output is correct
16 Correct 7 ms 12108 KB Output is correct
17 Correct 8 ms 12108 KB Output is correct
18 Correct 7 ms 12100 KB Output is correct
19 Correct 7 ms 12108 KB Output is correct
20 Correct 7 ms 12236 KB Output is correct
21 Correct 7 ms 12108 KB Output is correct
22 Correct 7 ms 12108 KB Output is correct
23 Correct 7 ms 12024 KB Output is correct
24 Correct 7 ms 12108 KB Output is correct
25 Correct 9 ms 12012 KB Output is correct
26 Correct 7 ms 12116 KB Output is correct
27 Correct 7 ms 12112 KB Output is correct
28 Correct 7 ms 12024 KB Output is correct
29 Correct 7 ms 12108 KB Output is correct
30 Correct 8 ms 12108 KB Output is correct
31 Correct 8 ms 12236 KB Output is correct
32 Correct 8 ms 12236 KB Output is correct
33 Correct 9 ms 12236 KB Output is correct
34 Correct 8 ms 12236 KB Output is correct
35 Correct 8 ms 12236 KB Output is correct
36 Correct 8 ms 12236 KB Output is correct
37 Correct 8 ms 12108 KB Output is correct
38 Correct 8 ms 12108 KB Output is correct
39 Correct 8 ms 12208 KB Output is correct
40 Correct 8 ms 12236 KB Output is correct
41 Correct 8 ms 12236 KB Output is correct
42 Correct 8 ms 12236 KB Output is correct
43 Correct 8 ms 12236 KB Output is correct
44 Correct 8 ms 12236 KB Output is correct
45 Correct 10 ms 12212 KB Output is correct
46 Correct 30 ms 16048 KB Output is correct
47 Correct 31 ms 17416 KB Output is correct
48 Correct 35 ms 17988 KB Output is correct
49 Correct 36 ms 19100 KB Output is correct
50 Correct 41 ms 19268 KB Output is correct
51 Correct 39 ms 18116 KB Output is correct
52 Correct 28 ms 15072 KB Output is correct
53 Correct 16 ms 13900 KB Output is correct
54 Correct 34 ms 17320 KB Output is correct
55 Correct 36 ms 18844 KB Output is correct
56 Correct 31 ms 18716 KB Output is correct
57 Correct 30 ms 17764 KB Output is correct
58 Correct 32 ms 18112 KB Output is correct
59 Correct 32 ms 18832 KB Output is correct
60 Correct 33 ms 18756 KB Output is correct
61 Correct 116 ms 33696 KB Output is correct
62 Correct 112 ms 35132 KB Output is correct
63 Correct 128 ms 38836 KB Output is correct
64 Correct 155 ms 43840 KB Output is correct
65 Correct 150 ms 48200 KB Output is correct
66 Correct 159 ms 42776 KB Output is correct
67 Correct 135 ms 36624 KB Output is correct
68 Correct 67 ms 24360 KB Output is correct
69 Correct 148 ms 38512 KB Output is correct
70 Correct 156 ms 46060 KB Output is correct
71 Correct 135 ms 45232 KB Output is correct
72 Correct 130 ms 40988 KB Output is correct
73 Correct 136 ms 44456 KB Output is correct
74 Correct 152 ms 46656 KB Output is correct
75 Correct 147 ms 46624 KB Output is correct