Submission #371087

#TimeUsernameProblemLanguageResultExecution timeMemory
371087nicolaalexandraBigger 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]; int sum = v[1], sol = 1; i = 1; while (i < n){ sol++; int j = i, sum2 = 0; while (j < n && sum2 < sum){ j++; sum2 += v[j]; } while (i < j && sum + v[i+1] <= sum2 - v[i+1]){ sum += v[i+1]; sum2 -= v[i+1]; i++; } i = j; sum = sum2; } 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...