Submission #1131131

#TimeUsernameProblemLanguageResultExecution timeMemory
1131131TsaganaBigger segments (IZhO19_segments)C++20
100 / 100
85 ms12104 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int dp[500001]; int a[500001]; int b[500001]; void solve () { int n, m; cin >> n; for (int i = 1; i <= n; i++) {cin >> a[i]; a[i] += a[i-1];} for (int i = 1; i <= n; i++) { b[i] = max(b[i], b[i-1]); dp[i] = dp[b[i]]+1; int k = 2 * a[i] - a[b[i]]; int p = lb(a+1, a+n+1, k) - a; b[p] = max(b[p], i); } cout << dp[n] << '\n'; } signed main() {IOS solve(); return 0;}
#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...