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 MOD 1000000007
#define ff first
#define ss second
#define N 500005
typedef long long ll;
const ll mx = 1e9 + 100005;
using namespace std;
ll a[N], M[N], H[N], sum[N];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
for(int i = 1; i <= n; i++){
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
for(int i = 1; i <= n; i++){
for(int j = i - 1; j >= 0; j--){
if(sum[i] - sum[j] >= M[j]){
M[i] = sum[i] - sum[j];
H[i] = H[j] + 1;
break;
}
}
}
cout << H[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... |