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>
#define DIM 500010
using namespace std;
int v[DIM];
int n,i;
int main (){
//ifstream cin ("date.in");
//ofstream cout ("date.out");
cin>>n;
for (i=1;i<=n;i++)
cin>>v[i];
long long sum = v[1]; int sol = 1;
i = 1;
while (i < n){
sol++;
int j = i; long long sum2 = 0;
while (j < n && sum2 < sum){
j++;
sum2 += v[j];
}
while (i < j && sum + v[i+1] <= sum2 - v[i+1]){
sum += v[i+1];
sum2 -= v[i+1];
i++;
}
i = j;
sum = sum2;
}
cout<<sol;
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... |