Submission #1113250

#TimeUsernameProblemLanguageResultExecution timeMemory
1113250stdfloatBigger segments (IZhO19_segments)C++17
27 / 100
1575 ms70928 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ff first #define ss second #define pii pair<int, int> #define all(v) (v).begin(), (v).end() int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (auto &i : a) cin >> i; vector<vector<ll>> dp(n, vector<ll>(n, LLONG_MAX)); for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { ll sm = 0; for (int k = j; k >= 0; k--) { sm += a[k]; if (i && k && dp[k - 1][i - 1] <= sm) { dp[j][i] = sm; break; } } if (!i) dp[j][0] = sm; } } for (int i = 0; i <= n; i++) if (i == n || dp[n - 1][i] == LLONG_MAX) return cout << i, 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...