Submission #853932

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