Submission #900322

#TimeUsernameProblemLanguageResultExecution timeMemory
900322Perl32Bigger segments (IZhO19_segments)C++14
13 / 100
1 ms348 KiB
//I wrote this code 4 u <3 #include <bits/stdc++.h> using namespace std; using ll = long long; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif signed main(int32_t argc, char *argv[]) { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<ll> pref(n + 1); partial_sum(a.begin(), a.end(), pref.begin() + 1); vector<int> dp(n + 1), id(n + 2); for (int i = 1; i <= n; ++i) { id[i] = max(id[i], id[i - 1]); dp[i] = dp[id[i]] + 1; int j = lower_bound(pref.begin() + 1, pref.end(), 2 * pref[i] - pref[id[i]]) - pref.begin(); id[j] = max(id[j], 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...