Submission #841355

#TimeUsernameProblemLanguageResultExecution timeMemory
841355Elvin_FritlBigger segments (IZhO19_segments)C++17
0 / 100
1 ms296 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5050 , inf = 1e9 + 199; int32_t main() { /// freopen("subsequence.in","r",stdin); /// freopen("subsequence.out","w",stdout); int n; cin>>n; vector<int>a(n); for(int i=0;i<n;i++){ cin>>a[i]; } int say = 1,preind = 0 , presum = a[0] , cursum = 0; for(int i=1;i<n;i++){ cursum += a[i]; if(cursum < presum){ continue; } while(preind + 1 < i){ if(presum + a[preind + 1] > cursum - a[preind + 1]){ break; } presum += a[preind + 1]; cursum -= a[preind + 1]; preind ++; } say++; presum = cursum; preind = i; cursum = 0; } if(cursum >= presum){ say++; } cout << say << 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...