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 newl '\n'
const int N = 5e5 + 10;
const int V = 1e7 + 10;
const long long INF = 1e18;
const long long M = 1e9 + 7;
int a[N + 1],n;
void readData(){
std::cin >> n;
for(int i = 1;i <= n;++i){
std::cin >> a[i];
}
}
int solve(){
long long last = 0,cnt = 0,j = 1,s = 0;
for(int i = 1;i <= n;++i){
s += a[i];
if(s >= last){
while(s - a[j] >= last + a[j]){
s -= a[j];
last += a[j];
++j;
}
++cnt;
last = s;
s = 0;
j = i + 1;
}
}
return cnt;
}
int main(){
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);std::cout.tie(nullptr);
readData();
std::cout << solve();
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... |