Submission #1108869

#TimeUsernameProblemLanguageResultExecution timeMemory
1108869LM1Bigger segments (IZhO19_segments)C++17
0 / 100
1 ms504 KiB
#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]; } dp[1][1]=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; }

Compilation message (stderr)

segments.cpp:11:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   11 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...