제출 #1125019

#제출 시각아이디문제언어결과실행 시간메모리
1125019nikatamlianiBigger segments (IZhO19_segments)C++20
27 / 100
54 ms2376 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N=500+5,mod=1e18+7; int n,p[N],ans,l,r,md,x; int dp[N][N]; signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for (int i=1; i<=n; i++) { cin>>p[i]; } for (int i=1; i<=n; i++){ p[i]+=p[i-1]; } for (int i = 0; i <= n; ++i) { for (int j = 0; j <= n; ++j) { dp[i][j] = mod; } } dp[0][0] = 0; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) { for (int k = 1; k <= i; ++k) { if (dp[k - 1][j - 1] <= p[i] - p[k - 1]) { dp[i][j] = p[i] - p[k - 1]; } } if (dp[i][j] != mod) { assert(dp[i][j] <= dp[i][j - 1]); } } } int ans = 0; for (int i = 1; i <= n; ++i) { if (dp[n][i] != mod) { ans = i; } } cout << ans << endl; }
#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...