Submission #843790

#TimeUsernameProblemLanguageResultExecution timeMemory
843790zwezdinvBigger segments (IZhO19_segments)C++17
0 / 100
1 ms456 KiB
#include<bits/stdc++.h> using namespace std; #define all(x) x.begin(), x.end() using ll = long long; int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; ll sm = 0; ll prev = 1; int ans = 0; vector<int> cur; for (int i = 0; i < n; ++i) { int x; cin >> x; sm += x; cur.push_back(x); if (sm >= prev) { ll mn = sm; for (auto j : cur) { sm -= j; prev += j; if (sm >= prev) mn = min(mn, sm); } cur.clear(); prev = mn; sm = 0; ans++; } } cout << ans; }
#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...