Submission #461920

# Submission time Handle Problem Language Result Execution time Memory
461920 2021-08-10T06:29:28 Z Jasiekstrz Cigle (COI21_cigle) C++17
100 / 100
966 ms 67572 KB
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
const int N=5e3;
const int PP=82e2;;
int tab[N+10];
int dp[N+10][N+10];
int pot;
int tree[2*PP+10];
int lazy[2*PP+10];
void add(int i,int l,int r,int ls,int rs,int c)
{
	if(r<ls || rs<l)
		return;
	if(ls<=l && r<=rs)
	{
		lazy[i]+=c;
		return;
	}
	int mid=(l+r)/2;
	add(2*i,l,mid,ls,rs,c);
	add(2*i+1,mid+1,r,ls,rs,c);
	tree[i]=max(tree[2*i]+lazy[2*i],tree[2*i+1]+lazy[2*i+1]);
	return;
}
int read()
{
	return tree[1]+lazy[1];
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	for(pot=1;pot<=n;pot*=2);
	for(int i=1;i<=n;i++)
		cin>>tab[i];

	for(int j=1;j<n;j++)
	{
		for(int k=0;k<=2*pot;k++)
			tree[k]=lazy[k]=0;
		for(int k=0;k<j;k++)
			tree[pot+k]=dp[j][k];
		for(int k=pot-1;k>0;k--)
			tree[k]=max(tree[2*k],tree[2*k+1]);
		
		int it=j;
		int s1=0,s2=tab[j];
		for(int i=j+1;i<=n;i++)
		{
			while(it>0 && s2<s1)
			{
				it--;
				s2+=tab[it];
			}
			if(s2==s1)
				add(1,1,pot,0,it-1,1);
			s1+=tab[i];
			dp[i][j]=read();
			//cerr<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
		}
	}

	int ans=0;
	for(int j=1;j<n;j++)
		ans=max(ans,dp[n][j]);
	cout<<ans<<"\n";
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 0 ms 332 KB Output is correct
9 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 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 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 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2756 KB Output is correct
2 Correct 7 ms 2764 KB Output is correct
3 Correct 6 ms 2764 KB Output is correct
4 Correct 6 ms 2764 KB Output is correct
5 Correct 7 ms 2764 KB Output is correct
6 Correct 8 ms 2772 KB Output is correct
7 Correct 8 ms 2764 KB Output is correct
8 Correct 8 ms 2764 KB Output is correct
9 Correct 7 ms 2764 KB Output is correct
10 Correct 6 ms 2764 KB Output is correct
11 Correct 6 ms 2764 KB Output is correct
12 Correct 6 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 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 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 5 ms 2756 KB Output is correct
22 Correct 7 ms 2764 KB Output is correct
23 Correct 6 ms 2764 KB Output is correct
24 Correct 6 ms 2764 KB Output is correct
25 Correct 7 ms 2764 KB Output is correct
26 Correct 8 ms 2772 KB Output is correct
27 Correct 8 ms 2764 KB Output is correct
28 Correct 8 ms 2764 KB Output is correct
29 Correct 7 ms 2764 KB Output is correct
30 Correct 6 ms 2764 KB Output is correct
31 Correct 6 ms 2764 KB Output is correct
32 Correct 6 ms 2764 KB Output is correct
33 Correct 6 ms 2764 KB Output is correct
34 Correct 6 ms 2844 KB Output is correct
35 Correct 6 ms 2816 KB Output is correct
36 Correct 7 ms 2748 KB Output is correct
37 Correct 7 ms 2828 KB Output is correct
38 Correct 7 ms 2764 KB Output is correct
39 Correct 4 ms 2776 KB Output is correct
40 Correct 4 ms 2764 KB Output is correct
41 Correct 4 ms 2764 KB Output is correct
42 Correct 3 ms 2764 KB Output is correct
43 Correct 3 ms 2764 KB Output is correct
44 Correct 3 ms 2764 KB Output is correct
45 Correct 3 ms 2764 KB Output is correct
46 Correct 3 ms 2752 KB Output is correct
47 Correct 3 ms 2764 KB Output is correct
48 Correct 3 ms 2764 KB Output is correct
49 Correct 3 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 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 1 ms 588 KB Output is correct
11 Correct 1 ms 588 KB Output is correct
12 Correct 1 ms 588 KB Output is correct
13 Correct 1 ms 588 KB Output is correct
14 Correct 1 ms 588 KB Output is correct
15 Correct 1 ms 588 KB Output is correct
16 Correct 1 ms 588 KB Output is correct
17 Correct 1 ms 588 KB Output is correct
18 Correct 1 ms 588 KB Output is correct
19 Correct 1 ms 588 KB Output is correct
20 Correct 1 ms 588 KB Output is correct
21 Correct 5 ms 2756 KB Output is correct
22 Correct 7 ms 2764 KB Output is correct
23 Correct 6 ms 2764 KB Output is correct
24 Correct 6 ms 2764 KB Output is correct
25 Correct 7 ms 2764 KB Output is correct
26 Correct 8 ms 2772 KB Output is correct
27 Correct 8 ms 2764 KB Output is correct
28 Correct 8 ms 2764 KB Output is correct
29 Correct 7 ms 2764 KB Output is correct
30 Correct 6 ms 2764 KB Output is correct
31 Correct 6 ms 2764 KB Output is correct
32 Correct 6 ms 2764 KB Output is correct
33 Correct 6 ms 2764 KB Output is correct
34 Correct 6 ms 2844 KB Output is correct
35 Correct 6 ms 2816 KB Output is correct
36 Correct 7 ms 2748 KB Output is correct
37 Correct 7 ms 2828 KB Output is correct
38 Correct 7 ms 2764 KB Output is correct
39 Correct 4 ms 2776 KB Output is correct
40 Correct 4 ms 2764 KB Output is correct
41 Correct 4 ms 2764 KB Output is correct
42 Correct 3 ms 2764 KB Output is correct
43 Correct 3 ms 2764 KB Output is correct
44 Correct 3 ms 2764 KB Output is correct
45 Correct 3 ms 2764 KB Output is correct
46 Correct 3 ms 2752 KB Output is correct
47 Correct 3 ms 2764 KB Output is correct
48 Correct 3 ms 2764 KB Output is correct
49 Correct 3 ms 2764 KB Output is correct
50 Correct 891 ms 67448 KB Output is correct
51 Correct 866 ms 67464 KB Output is correct
52 Correct 912 ms 67356 KB Output is correct
53 Correct 869 ms 67448 KB Output is correct
54 Correct 911 ms 67472 KB Output is correct
55 Correct 891 ms 67380 KB Output is correct
56 Correct 966 ms 67360 KB Output is correct
57 Correct 924 ms 67460 KB Output is correct
58 Correct 425 ms 67400 KB Output is correct
59 Correct 271 ms 67376 KB Output is correct
60 Correct 231 ms 67412 KB Output is correct
61 Correct 207 ms 67524 KB Output is correct
62 Correct 210 ms 67456 KB Output is correct
63 Correct 241 ms 67396 KB Output is correct
64 Correct 214 ms 67512 KB Output is correct
65 Correct 218 ms 67352 KB Output is correct
66 Correct 219 ms 67376 KB Output is correct
67 Correct 215 ms 67368 KB Output is correct
68 Correct 226 ms 67452 KB Output is correct
69 Correct 216 ms 67400 KB Output is correct
70 Correct 219 ms 67436 KB Output is correct
71 Correct 235 ms 67392 KB Output is correct
72 Correct 233 ms 67572 KB Output is correct