Submission #222710

#TimeUsernameProblemLanguageResultExecution timeMemory
222710nikatamlianiBigger segments (IZhO19_segments)C++14
0 / 100
5 ms384 KiB
# include <bits/stdc++.h> using namespace std; const int N = 2e5 + 10; int a[N]; int main(){ int n; cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i]; } int sum = a[1], ans = 1; for(int i = 2; i <= n; i++){ int j = i, cur = 0; while(j <= n && sum > cur){ cur += a[j]; j ++; } --j; if(cur < sum){ break; } for(int k = i; k <= j; k++){ if(sum + a[k] <= cur - a[k]){ sum += a[k]; cur -= a[k]; }else{ break; } } sum = cur; ans++; i = j; } cout << ans << '\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...