Submission #161887

# Submission time Handle Problem Language Result Execution time Memory
161887 2019-11-05T07:15:25 Z MvC Bigger segments (IZhO19_segments) C++11
27 / 100
1500 ms 72036 KB
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=3e3+50;
const int mod=1e9+7;
int n,i,nr,st,j,t;
ll l,sm,a[nmax],f[nmax][nmax],pr[nmax];
/*void rec(int l,int r,int opl,int opr)
{
	if(l>r)return;
	int mid=(l+r)/2,bst;
	for(int i=opl-1;i<min(opr,mid);i++)
	{
		if(f[k-1][i]<=pr[mid]-pr[i]<=f[k][mid])
		{
			f[k][mid]=f[k-1][i]+pr[mid]-pr[i];
			bst=i;
		}
	}
	rec(l,mid-1,opl,bst);
	rec(mid+1,r,bst,opr);
}*/
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
		pr[i]=pr[i-1]+a[i];
	}
	for(i=0;i<=n;i++)for(j=0;j<=n;j++)f[i][j]=llinf;
	f[0][0]=0;
	for(i=1;i<=n;i++)
	{
		for(j=i;j<=n;j++)
		{
			for(t=j-1;t>=0;t--)
			{
				if(f[i-1][t]<=pr[j]-pr[t])
				{
					f[i][j]=pr[j]-pr[t];
					break;
				}
			}
		}
		if(f[i][n]<llinf)nr=max(nr,i);
	}
	/*for(i=0;i<=n;i++)for(j=1;j<=n;j++)f[i][j]=llinf;
	for(i=1;i<=n;i++)
	{
		k++;
		rec(1,n,1,n);
		if(f[k][n]!=llinf)
	}*/
	cout<<nr<<endl;
	return 0;
}

Compilation message

segments.cpp:2:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("O3")
 
segments.cpp:3:0: warning: ignoring #pragma GCC optimization [-Wunknown-pragmas]
 #pragma GCC optimization("unroll-loops")
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 45 ms 4420 KB Output is correct
17 Correct 44 ms 4420 KB Output is correct
18 Correct 39 ms 4344 KB Output is correct
19 Correct 22 ms 4344 KB Output is correct
20 Correct 6 ms 4472 KB Output is correct
21 Correct 42 ms 4388 KB Output is correct
22 Correct 23 ms 3320 KB Output is correct
23 Correct 11 ms 2296 KB Output is correct
24 Correct 41 ms 4344 KB Output is correct
25 Correct 41 ms 4344 KB Output is correct
26 Correct 6 ms 4344 KB Output is correct
27 Correct 37 ms 4344 KB Output is correct
28 Correct 37 ms 4344 KB Output is correct
29 Correct 6 ms 4348 KB Output is correct
30 Correct 12 ms 4344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 45 ms 4420 KB Output is correct
17 Correct 44 ms 4420 KB Output is correct
18 Correct 39 ms 4344 KB Output is correct
19 Correct 22 ms 4344 KB Output is correct
20 Correct 6 ms 4472 KB Output is correct
21 Correct 42 ms 4388 KB Output is correct
22 Correct 23 ms 3320 KB Output is correct
23 Correct 11 ms 2296 KB Output is correct
24 Correct 41 ms 4344 KB Output is correct
25 Correct 41 ms 4344 KB Output is correct
26 Correct 6 ms 4344 KB Output is correct
27 Correct 37 ms 4344 KB Output is correct
28 Correct 37 ms 4344 KB Output is correct
29 Correct 6 ms 4348 KB Output is correct
30 Correct 12 ms 4344 KB Output is correct
31 Execution timed out 1572 ms 72036 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 45 ms 4420 KB Output is correct
17 Correct 44 ms 4420 KB Output is correct
18 Correct 39 ms 4344 KB Output is correct
19 Correct 22 ms 4344 KB Output is correct
20 Correct 6 ms 4472 KB Output is correct
21 Correct 42 ms 4388 KB Output is correct
22 Correct 23 ms 3320 KB Output is correct
23 Correct 11 ms 2296 KB Output is correct
24 Correct 41 ms 4344 KB Output is correct
25 Correct 41 ms 4344 KB Output is correct
26 Correct 6 ms 4344 KB Output is correct
27 Correct 37 ms 4344 KB Output is correct
28 Correct 37 ms 4344 KB Output is correct
29 Correct 6 ms 4348 KB Output is correct
30 Correct 12 ms 4344 KB Output is correct
31 Execution timed out 1572 ms 72036 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 504 KB Output is correct
6 Correct 3 ms 504 KB Output is correct
7 Correct 3 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 504 KB Output is correct
10 Correct 2 ms 504 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 504 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 2 ms 504 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 45 ms 4420 KB Output is correct
17 Correct 44 ms 4420 KB Output is correct
18 Correct 39 ms 4344 KB Output is correct
19 Correct 22 ms 4344 KB Output is correct
20 Correct 6 ms 4472 KB Output is correct
21 Correct 42 ms 4388 KB Output is correct
22 Correct 23 ms 3320 KB Output is correct
23 Correct 11 ms 2296 KB Output is correct
24 Correct 41 ms 4344 KB Output is correct
25 Correct 41 ms 4344 KB Output is correct
26 Correct 6 ms 4344 KB Output is correct
27 Correct 37 ms 4344 KB Output is correct
28 Correct 37 ms 4344 KB Output is correct
29 Correct 6 ms 4348 KB Output is correct
30 Correct 12 ms 4344 KB Output is correct
31 Execution timed out 1572 ms 72036 KB Time limit exceeded
32 Halted 0 ms 0 KB -