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;
int main(){
int n,i,a[100000],j;
cin >> n;
for(i = 1;i <= n;i++){
cin >> a[i];
}
int dp[n+1],cnt[n+1];
dp[1] = a[1];
dp[0] = 0;
cnt[0] = 0;
cnt[1] = 1;
for(i = 2;i <= n;i++){
int ol = 0;
for(j = i;j >= 1;j--){
ol+= a[j];
if(ol >= dp[j-1]){
cnt[i] = cnt[j-1] + 1;
break;
}
}
dp[i] = ol;
}
cout << cnt[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... |