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;
const ll inf = 1e18 + 50;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<ll> a(n);
for (auto & x: a) cin >> x;
vector<ll> c;
ll last = 1, cur = 0, ans = 0;
for (int i = 0; i < n; ++i) {
cur += a[i];
c.push_back(a[i]);
if (cur >= last) {
reverse(c.begin(), c.end());
while (c.size() && c.back() * 2LL + last <= cur) {
last += c.back();
cur -= c.back();
c.pop_back();
}
last = cur;
c.clear();
cur = 0;
ans++;
}
}
cout << ans << '\n';
return 0;
}
# | 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... |