Submission #1172037

#TimeUsernameProblemLanguageResultExecution timeMemory
1172037AtabayRajabliBigger segments (IZhO19_segments)C++20
27 / 100
1597 ms70728 KiB
#include <bits/stdc++.h> #define int long long #define all(v) v.begin(), v.end() using namespace std; const int sz = 3e3 + 1, inf = 1e18; int n, a[sz], dp[sz][sz]; signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(int i = 1; i <= n; i++) { cin >> a[i]; a[i] += a[i - 1]; } // i1, i2, i3, i4, i5 // a[i5] - a[i4] >= a[i4] - a[i3] >= a[i3] - a[i2] >= a[i2] - a[i1] >= a[i1] for(int i = 0; i <= n; i++) fill(dp[i], dp[i] + 1 + n, inf); dp[0][0] = 0; for(int i = 1; i <= n; i++) { for(int j = i; j <= n; j++) { for(int l = i - 1; l < j; l++) { int lst = a[j] - a[l]; if(lst >= dp[i - 1][l]) dp[i][j] = min(dp[i][j], lst); } } } for(int i = n; i >= 1; i--) { if(dp[i][n] < inf) { cout << i; 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...