Submission #373993

#TimeUsernameProblemLanguageResultExecution timeMemory
373993mariowongBigger segments (IZhO19_segments)C++14
27 / 100
1594 ms71020 KiB
#include <bits/stdc++.h> using namespace std; long long n,a[3005],dp[3005][3005],ps[3005],ans; int main(){ ios::sync_with_stdio(false); cin >> n; for (int i=1;i<=n;i++){ cin >> a[i]; ps[i]=ps[i-1]+a[i]; } for (int i=1;i<=n;i++){ for (int j=1;j<=n;j++){ dp[i][j]=1e18; } } for (int i=1;i<=n;i++){ dp[i][1]=ps[i]; for (int j=2;j<=n;j++){ for (int k=1;k<i;k++){ if (dp[k][j-1] <= ps[i]-ps[k]) dp[i][j]=min(dp[i][j],ps[i]-ps[k]); } } } for (int i=1;i<=n;i++){ if (dp[n][i] != 1e18) ans=i; } cout << ans << "\n"; return 0; }
#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...