Submission #1114348

#TimeUsernameProblemLanguageResultExecution timeMemory
1114348vjudge1Bigger segments (IZhO19_segments)C++17
27 / 100
1576 ms71008 KiB
#include <bits/stdc++.h> using namespace std; #define int long long signed main() { int n; cin >> n; vector<int> a(n + 1), pref(n + 1); for (int i = 1; i<= n; i++){ cin >> a[i]; pref[i] = pref[i - 1] + a[i]; } vector<vector<int>> dp(n + 1, vector<int> (n + 1, 1e18)); dp[0][0] = 0; for (int i = 1; i <= n; i++){ for (int j = 0; j < i; j++){ for (int k = i - 1; k >= 0; k--){ int suma = pref[i] - pref[k]; if (suma >= dp[k][j]){ dp[i][j + 1] = min(dp[i][j + 1], suma); break; } } } } int ans = 0; for (int i = 1; i <= n; i++){ if (dp[n][i] != 1e18) ans = max(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...