Submission #945185

#TimeUsernameProblemLanguageResultExecution timeMemory
945185fzyzzz_zBigger segments (IZhO19_segments)C++17
0 / 100
0 ms500 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1e18 + 50; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n; cin >> n; vector<ll> a(n); for (auto & x: a) cin >> x; vector<ll> c; ll last = 1, cur = 0, ans = 0; for (int i = 0; i < n; ++i) { cur += a[i]; c.push_back(a[i]); if (cur >= last) { reverse(c.begin(), c.end()); while (c.size() && c.back() * 2LL + last <= cur) { last += c.back(); cur -= c.back(); c.pop_back(); } last = cur; c.clear(); cur = 0; ans++; } } cout << ans << '\n'; 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...