This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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<ll> dp(n, LLONG_MAX);
for (int i = 0; i < n; i++) {
for (int j = n - 1; j >= 0; j--) {
dp[j] = LLONG_MAX;
ll sm = 0;
for (int k = j; k >= 0; k--) {
sm += a[k];
if (i && k && dp[k - 1] <= sm) {
dp[j] = sm; break;
}
}
if (!i) dp[j] = sm;
}
if (dp[n - 1] == LLONG_MAX) return cout << i, 0;
}
cout << n;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |