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;
#define all(x) x.begin(), x.end()
using ll = long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
ll sm = 0;
ll prev = 1;
int ans = 0;
vector<int> cur;
for (int i = 0; i < n; ++i) {
int x;
cin >> x;
sm += x;
cur.push_back(x);
if (sm >= prev) {
ll mn = sm;
for (auto j : cur) {
sm -= j;
prev += j;
if (sm >= prev) mn = min(mn, sm);
}
cur.clear();
prev = mn;
sm = 0;
ans++;
}
}
cout << ans;
}
# | 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... |