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 pb push_back
#define LL long long
#define Kultivator ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const LL Mxn = 1e6 + 7;
const LL Mod = 1e9 + 7;
const LL Inf = 1e14 + 7;
LL N, Pref[Mxn], Mx[Mxn], Dp[Mxn], A;
int main() {
Kultivator;
cin >> N;
for(int i = 1; i <= N; i++){
cin >> A;
Pref[i] = (Pref[i - 1] + A);
}
for(int i = 1; i <= N; i++){
Dp[i] = Dp[Mx[i]] + 1;
int ind = lower_bound(Pref, Pref + N + 1, (2 * Pref[i]) - Pref[Mx[i]]) - Pref;
Mx[ind] = max(Mx[i], (LL)i);
}
cout << Dp[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... |