Submission #522905

#TimeUsernameProblemLanguageResultExecution timeMemory
522905lucriBigger segments (IZhO19_segments)C++17
0 / 100
0 ms204 KiB
#include <iostream> using namespace std; long long n,v[500010],suma[500010],ans; int main() { cin>>n; for(int i=1;i<=n;++i) { cin>>v[i]; } ans=1; suma[1]=v[1]; int poz=2; for(int i=2;i<=n;++i) { suma[ans+1]+=v[i]; if(suma[ans]<=suma[ans+1]) { ++ans; while(suma[ans]-v[poz]>=v[poz]+suma[ans-1]) { suma[ans]-=v[poz]; suma[ans-1]+=v[poz]; ++poz; } poz=i+1; } } cout<<ans; 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...