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;
long long n,a[500005],dp[500005],ps[500005],chk[500005];
queue <pair<long long,long long> > q;
pair<long long,long long> now;
int main(){
ios::sync_with_stdio(false);
cin >> n;
for (int i=1;i<=n;i++){
cin >> a[i];
ps[i]=ps[i-1]+a[i];
}
for (int i=1;i<=n;i++){
while (!q.empty() && q.front().first <= ps[i]-ps[q.front().second]){
now=q.front();
q.pop();
}
dp[i]=dp[now.second]+1;
chk[i]=ps[i]-ps[now.second];
q.push(make_pair(ps[i]-ps[now.second],i));
}
for (int i=1;i<n;i++){
if (chk[i] > chk[i+1]){
while (true){
}
}
}
cout << dp[n] << "\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... |