Submission #853935

#TimeUsernameProblemLanguageResultExecution timeMemory
853935Trisanu_DasBigger segments (IZhO19_segments)C++17
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define int long long pair<int,long long> dp[500005]; signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; int a[n + 1]; for(int i = 1; i <= n; i++) cin >> a[i]; for(int i = 2; i <= n; i++) a[i] += a[i - 1]; dp[0].ff = 1; dp[0].ss = 0; for(int i = 1; i <= n; i++){ dp[i] = max(dp[i], dp[i - 1]); int x = lower_bound(a + 1, a + n + 1, 2 * a[i] - dp[i].ss) - a; dp[x] = max(dp[x], {dp[i].ff + 1, a[i]}); } cout << dp[n - 1].ff << '\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...