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;
const int N = 2e5 + 10;
int a[N];
int main(){
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
}
int sum = a[1], ans = 1;
for(int i = 2; i <= n; i++){
int j = i, cur = 0;
while(j <= n && sum > cur){
cur += a[j];
j ++;
} --j;
if(cur < sum){
break;
}
for(int k = i; k <= j; k++){
if(sum + a[k] <= cur - a[k]){
sum += a[k];
cur -= a[k];
}else{
break;
}
}
sum = cur;
ans++;
i = j;
}
cout << ans << '\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... |