Submission #371089

#TimeUsernameProblemLanguageResultExecution timeMemory
371089nicolaalexandraBigger segments (IZhO19_segments)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> #define DIM 500010 using namespace std; int v[DIM]; int n,i; int main (){ //ifstream cin ("date.in"); //ofstream cout ("date.out"); cin>>n; for (i=1;i<=n;i++) cin>>v[i]; long long sum = v[1]; int sol = 1; i = 1; while (i < n){ int j = i; long long sum2 = 0; while (j < n && sum2 < sum){ j++; sum2 += v[j]; } if (sum2 < sum) break; while (i < j && sum + v[i+1] <= sum2 - v[i+1]){ sum += v[i+1]; sum2 -= v[i+1]; i++; } i = j; sum = sum2; sol++; } cout<<sol; 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...