Submission #371088

#TimeUsernameProblemLanguageResultExecution timeMemory
371088nicolaalexandraBigger segments (IZhO19_segments)C++14
0 / 100
1 ms364 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){ sol++; int j = i; long long 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...