Submission #1108874

# Submission time Handle Problem Language Result Execution time Memory
1108874 2024-11-05T13:51:00 Z LM1 Bigger segments (IZhO19_segments) C++14
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=505;
int n,a[N],dp[N][N],pr[N],ans;
main(){
	ios_base::sync_with_stdio(NULL);cin.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		pr[i]=pr[i-1]+a[i];
	}
	for(int i=1;i<=n;i++){
		dp[1][i]=1;
	}
	for(int j=1;j<=n;j++){
		for(int i=1;i<=j;i++){
			for(int i1=i-1;i1>=1;i1--){
				int j1=i-1;
				int sum=pr[j]-pr[i-1];
				int sum1=pr[j1]-pr[i1-1];
				if(sum1>sum)continue;
				dp[i][j]=max(dp[i][j],dp[i1][j1]+1);
			}
		}
	}
	for(int i=1;i<=n;i++)ans=max(ans,dp[i][n]);
	cout<<ans;
//	for(int i=1;i<=n;i++){
//		for(int j=i;j<=n;j++){
//			cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
//		}
//	}
}

Compilation message

segments.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Incorrect 1 ms 336 KB Output isn't correct
5 Halted 0 ms 0 KB -