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;
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<pair<int, ll>> dp(n + 1, {0, 0});
for (int i = 0; i < n; i++) {
ll sum = 0;
for (int j = i; j >= 0; j--) {
sum += a[j];
auto [x, y] = dp[j];
if (-y <= sum) {
dp[i + 1] = {x + 1, -sum};
break;
}
}
}
for (int i = 1; i <= n; i++) {
if (dp[i - 1].first == dp[i].first) {
assert(dp[i - 1].second >= dp[i].second);
}
}
cout << dp[n].first;
return 6/22;
}
# | 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... |