Submission #434926

# Submission time Handle Problem Language Result Execution time Memory
434926 2021-06-22T10:32:58 Z dqhungdl Cigle (COI21_cigle) C++17
100 / 100
365 ms 178884 KB
#include <bits/stdc++.h>
using namespace std;

const int MAX=5005;
int N,S[MAX],mark[MAX][MAX],f[MAX][MAX],maxf[MAX][MAX];

int main() {
#ifdef ACM
	freopen("input","r",stdin);
#endif
	cin>>N;
	for(int i=1;i<=N;i++) {
		cin>>S[i];
		S[i]+=S[i-1];
	}
	for(int i=1;i<=N;i++) {
		int cur=i;
		for(int j=i+1;j<=N;j++) {
			while(cur>0&&S[i]-S[cur-1]<S[j]-S[i])
				cur--;
			if(cur>0&&S[i]-S[cur-1]==S[j]-S[i])
				mark[i][j]=cur;
		}
	}
	for(int i=0;i<N;i++) {
		int cnt=0,maxVal=maxf[i][i-1];
		for(int j=i+1;j<=N;j++) {
			f[i][j]=maxVal;
			if(mark[i][j]>1) {
				cnt++;
				maxVal=max(maxVal,maxf[i][mark[i][j]-2]+cnt);
			}
		}
		for(int j=i+1;j<=N;j++)
			maxf[j][i]=max(maxf[j][i-1],f[i][j]);
	}
	int rs=0;
	for(int i=0;i<N;i++)
		rs=max(rs,f[i][N]);
	cout<<rs;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 1320 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
14 Correct 2 ms 1256 KB Output is correct
15 Correct 1 ms 1228 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 7500 KB Output is correct
2 Correct 6 ms 7456 KB Output is correct
3 Correct 6 ms 7500 KB Output is correct
4 Correct 6 ms 7488 KB Output is correct
5 Correct 8 ms 7500 KB Output is correct
6 Correct 8 ms 7468 KB Output is correct
7 Correct 6 ms 7500 KB Output is correct
8 Correct 7 ms 7500 KB Output is correct
9 Correct 6 ms 7500 KB Output is correct
10 Correct 6 ms 7500 KB Output is correct
11 Correct 7 ms 7504 KB Output is correct
12 Correct 6 ms 7500 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 1320 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
14 Correct 2 ms 1256 KB Output is correct
15 Correct 1 ms 1228 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Correct 6 ms 7500 KB Output is correct
22 Correct 6 ms 7456 KB Output is correct
23 Correct 6 ms 7500 KB Output is correct
24 Correct 6 ms 7488 KB Output is correct
25 Correct 8 ms 7500 KB Output is correct
26 Correct 8 ms 7468 KB Output is correct
27 Correct 6 ms 7500 KB Output is correct
28 Correct 7 ms 7500 KB Output is correct
29 Correct 6 ms 7500 KB Output is correct
30 Correct 6 ms 7500 KB Output is correct
31 Correct 7 ms 7504 KB Output is correct
32 Correct 6 ms 7500 KB Output is correct
33 Correct 6 ms 7500 KB Output is correct
34 Correct 6 ms 7500 KB Output is correct
35 Correct 6 ms 7500 KB Output is correct
36 Correct 6 ms 7500 KB Output is correct
37 Correct 8 ms 7500 KB Output is correct
38 Correct 7 ms 7500 KB Output is correct
39 Correct 6 ms 7468 KB Output is correct
40 Correct 6 ms 5324 KB Output is correct
41 Correct 7 ms 6284 KB Output is correct
42 Correct 6 ms 6988 KB Output is correct
43 Correct 6 ms 6476 KB Output is correct
44 Correct 6 ms 5708 KB Output is correct
45 Correct 7 ms 6604 KB Output is correct
46 Correct 6 ms 6348 KB Output is correct
47 Correct 6 ms 5964 KB Output is correct
48 Correct 5 ms 6348 KB Output is correct
49 Correct 6 ms 6604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 460 KB Output is correct
2 Correct 1 ms 460 KB Output is correct
3 Correct 1 ms 460 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 1 ms 460 KB Output is correct
10 Correct 1 ms 1320 KB Output is correct
11 Correct 1 ms 1228 KB Output is correct
12 Correct 1 ms 1228 KB Output is correct
13 Correct 1 ms 1228 KB Output is correct
14 Correct 2 ms 1256 KB Output is correct
15 Correct 1 ms 1228 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 1100 KB Output is correct
18 Correct 1 ms 1100 KB Output is correct
19 Correct 1 ms 1100 KB Output is correct
20 Correct 2 ms 1100 KB Output is correct
21 Correct 6 ms 7500 KB Output is correct
22 Correct 6 ms 7456 KB Output is correct
23 Correct 6 ms 7500 KB Output is correct
24 Correct 6 ms 7488 KB Output is correct
25 Correct 8 ms 7500 KB Output is correct
26 Correct 8 ms 7468 KB Output is correct
27 Correct 6 ms 7500 KB Output is correct
28 Correct 7 ms 7500 KB Output is correct
29 Correct 6 ms 7500 KB Output is correct
30 Correct 6 ms 7500 KB Output is correct
31 Correct 7 ms 7504 KB Output is correct
32 Correct 6 ms 7500 KB Output is correct
33 Correct 6 ms 7500 KB Output is correct
34 Correct 6 ms 7500 KB Output is correct
35 Correct 6 ms 7500 KB Output is correct
36 Correct 6 ms 7500 KB Output is correct
37 Correct 8 ms 7500 KB Output is correct
38 Correct 7 ms 7500 KB Output is correct
39 Correct 6 ms 7468 KB Output is correct
40 Correct 6 ms 5324 KB Output is correct
41 Correct 7 ms 6284 KB Output is correct
42 Correct 6 ms 6988 KB Output is correct
43 Correct 6 ms 6476 KB Output is correct
44 Correct 6 ms 5708 KB Output is correct
45 Correct 7 ms 6604 KB Output is correct
46 Correct 6 ms 6348 KB Output is correct
47 Correct 6 ms 5964 KB Output is correct
48 Correct 5 ms 6348 KB Output is correct
49 Correct 6 ms 6604 KB Output is correct
50 Correct 292 ms 178728 KB Output is correct
51 Correct 299 ms 178760 KB Output is correct
52 Correct 268 ms 178796 KB Output is correct
53 Correct 273 ms 178884 KB Output is correct
54 Correct 276 ms 178772 KB Output is correct
55 Correct 274 ms 178844 KB Output is correct
56 Correct 339 ms 178748 KB Output is correct
57 Correct 365 ms 178800 KB Output is correct
58 Correct 330 ms 178584 KB Output is correct
59 Correct 321 ms 177608 KB Output is correct
60 Correct 341 ms 142712 KB Output is correct
61 Correct 314 ms 157788 KB Output is correct
62 Correct 328 ms 157316 KB Output is correct
63 Correct 299 ms 168072 KB Output is correct
64 Correct 293 ms 167140 KB Output is correct
65 Correct 319 ms 162740 KB Output is correct
66 Correct 313 ms 161876 KB Output is correct
67 Correct 288 ms 157716 KB Output is correct
68 Correct 298 ms 155908 KB Output is correct
69 Correct 280 ms 156436 KB Output is correct
70 Correct 306 ms 159632 KB Output is correct
71 Correct 345 ms 160836 KB Output is correct
72 Correct 299 ms 170388 KB Output is correct