Submission #344697

#TimeUsernameProblemLanguageResultExecution timeMemory
344697koketsuBigger segments (IZhO19_segments)C++14
0 / 100
1 ms364 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...