Submission #1022853

#TimeUsernameProblemLanguageResultExecution timeMemory
1022853yellowtoadBigger segments (IZhO19_segments)C++17
0 / 100
0 ms348 KiB
#include <iostream> using namespace std; long long n, a[500010], l, r, lst, cnt, sum; int main() { cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; l = r = 1; sum = a[1]; while (r <= n) { if (sum < lst) sum += a[++r]; else { while ((l < r) && (sum-a[l] >= lst+a[l])) { lst += a[l]; sum -= a[l++]; } lst = sum; cnt++; l = ++r; sum = a[r]; } } cout << cnt << endl; }
#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...