Submission #420474

# Submission time Handle Problem Language Result Execution time Memory
420474 2021-06-08T11:42:17 Z Pyqe Cigle (COI21_cigle) C++14
100 / 100
540 ms 235308 KB
#include <bits/stdc++.h>

using namespace std;

const long long inf=1e18;
long long n,ps[5069],px[2][5069][5069],fh[5069],fq[5069];

int main()
{
	long long i,j,k,z=0;
	
	scanf("%lld",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%lld",ps+i);
		ps[i]+=ps[i-1];
	}
	for(i=1;i<=n;i++)
	{
		px[0][i][0]=-inf;
		px[0][i][1]=-inf;
		px[1][i][1]=-inf;
		for(j=0;j<i;j++)
		{
			k=max(px[0][j][fh[j]]+fq[j],px[1][j][fh[j]+1]);
			z=max(z,k);
			px[0][i][j+2]=max(px[0][i][j+1],k);
			px[1][i][j+2]=k;
			for(;fh[j]&&ps[j]-ps[fh[j]-1]<=ps[i]-ps[j];fh[j]--)
			{
				fq[j]+=ps[j]-ps[fh[j]-1]==ps[i]-ps[j];
				px[1][j][fh[j]]=max(px[1][j][fh[j]+1],px[1][j][fh[j]]+fq[j]);
			}
		}
		px[1][i][i+2]=-inf;
		fh[i]=i+1;
	}
	printf("%lld\n",z);
}

Compilation message

cigle.cpp: In function 'int main()':
cigle.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  scanf("%lld",&n);
      |  ~~~~~^~~~~~~~~~~
cigle.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |   scanf("%lld",ps+i);
      |   ~~~~~^~~~~~~~~~~~~
# 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 424 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 424 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 948 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 932 KB Output is correct
14 Correct 1 ms 940 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 940 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 972 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 6372 KB Output is correct
2 Correct 5 ms 6348 KB Output is correct
3 Correct 5 ms 6348 KB Output is correct
4 Correct 5 ms 6348 KB Output is correct
5 Correct 5 ms 6312 KB Output is correct
6 Correct 6 ms 6348 KB Output is correct
7 Correct 5 ms 6348 KB Output is correct
8 Correct 5 ms 6348 KB Output is correct
9 Correct 5 ms 6352 KB Output is correct
10 Correct 5 ms 6348 KB Output is correct
11 Correct 5 ms 6312 KB Output is correct
12 Correct 5 ms 6348 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 424 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 948 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 932 KB Output is correct
14 Correct 1 ms 940 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 940 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 972 KB Output is correct
21 Correct 5 ms 6372 KB Output is correct
22 Correct 5 ms 6348 KB Output is correct
23 Correct 5 ms 6348 KB Output is correct
24 Correct 5 ms 6348 KB Output is correct
25 Correct 5 ms 6312 KB Output is correct
26 Correct 6 ms 6348 KB Output is correct
27 Correct 5 ms 6348 KB Output is correct
28 Correct 5 ms 6348 KB Output is correct
29 Correct 5 ms 6352 KB Output is correct
30 Correct 5 ms 6348 KB Output is correct
31 Correct 5 ms 6312 KB Output is correct
32 Correct 5 ms 6348 KB Output is correct
33 Correct 5 ms 6352 KB Output is correct
34 Correct 5 ms 6348 KB Output is correct
35 Correct 5 ms 6348 KB Output is correct
36 Correct 5 ms 6348 KB Output is correct
37 Correct 6 ms 6348 KB Output is correct
38 Correct 5 ms 6316 KB Output is correct
39 Correct 5 ms 6272 KB Output is correct
40 Correct 5 ms 6348 KB Output is correct
41 Correct 5 ms 6352 KB Output is correct
42 Correct 5 ms 6348 KB Output is correct
43 Correct 5 ms 6348 KB Output is correct
44 Correct 5 ms 6312 KB Output is correct
45 Correct 5 ms 6348 KB Output is correct
46 Correct 5 ms 6348 KB Output is correct
47 Correct 5 ms 6348 KB Output is correct
48 Correct 5 ms 6348 KB Output is correct
49 Correct 5 ms 6348 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 424 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 948 KB Output is correct
11 Correct 1 ms 972 KB Output is correct
12 Correct 1 ms 972 KB Output is correct
13 Correct 1 ms 932 KB Output is correct
14 Correct 1 ms 940 KB Output is correct
15 Correct 1 ms 972 KB Output is correct
16 Correct 1 ms 972 KB Output is correct
17 Correct 1 ms 972 KB Output is correct
18 Correct 1 ms 940 KB Output is correct
19 Correct 1 ms 944 KB Output is correct
20 Correct 1 ms 972 KB Output is correct
21 Correct 5 ms 6372 KB Output is correct
22 Correct 5 ms 6348 KB Output is correct
23 Correct 5 ms 6348 KB Output is correct
24 Correct 5 ms 6348 KB Output is correct
25 Correct 5 ms 6312 KB Output is correct
26 Correct 6 ms 6348 KB Output is correct
27 Correct 5 ms 6348 KB Output is correct
28 Correct 5 ms 6348 KB Output is correct
29 Correct 5 ms 6352 KB Output is correct
30 Correct 5 ms 6348 KB Output is correct
31 Correct 5 ms 6312 KB Output is correct
32 Correct 5 ms 6348 KB Output is correct
33 Correct 5 ms 6352 KB Output is correct
34 Correct 5 ms 6348 KB Output is correct
35 Correct 5 ms 6348 KB Output is correct
36 Correct 5 ms 6348 KB Output is correct
37 Correct 6 ms 6348 KB Output is correct
38 Correct 5 ms 6316 KB Output is correct
39 Correct 5 ms 6272 KB Output is correct
40 Correct 5 ms 6348 KB Output is correct
41 Correct 5 ms 6352 KB Output is correct
42 Correct 5 ms 6348 KB Output is correct
43 Correct 5 ms 6348 KB Output is correct
44 Correct 5 ms 6312 KB Output is correct
45 Correct 5 ms 6348 KB Output is correct
46 Correct 5 ms 6348 KB Output is correct
47 Correct 5 ms 6348 KB Output is correct
48 Correct 5 ms 6348 KB Output is correct
49 Correct 5 ms 6348 KB Output is correct
50 Correct 508 ms 235080 KB Output is correct
51 Correct 514 ms 234960 KB Output is correct
52 Correct 514 ms 235144 KB Output is correct
53 Correct 516 ms 234948 KB Output is correct
54 Correct 508 ms 235308 KB Output is correct
55 Correct 513 ms 235160 KB Output is correct
56 Correct 525 ms 234980 KB Output is correct
57 Correct 525 ms 234972 KB Output is correct
58 Correct 524 ms 234932 KB Output is correct
59 Correct 519 ms 234948 KB Output is correct
60 Correct 525 ms 235024 KB Output is correct
61 Correct 523 ms 234936 KB Output is correct
62 Correct 527 ms 235180 KB Output is correct
63 Correct 525 ms 234960 KB Output is correct
64 Correct 521 ms 234948 KB Output is correct
65 Correct 527 ms 234964 KB Output is correct
66 Correct 523 ms 234960 KB Output is correct
67 Correct 521 ms 235064 KB Output is correct
68 Correct 538 ms 235180 KB Output is correct
69 Correct 540 ms 235124 KB Output is correct
70 Correct 512 ms 234976 KB Output is correct
71 Correct 522 ms 235112 KB Output is correct
72 Correct 519 ms 235012 KB Output is correct