Submission #341573

#TimeUsernameProblemLanguageResultExecution timeMemory
341573katearimaBigger segments (IZhO19_segments)C++14
0 / 100
1 ms384 KiB
#include <bits/stdc++.h> using namespace std; const int N=500005; int a[N], oldS, n, sum, ans; main(){ cin>>n; for(int i=0; i<n; i++){ cin>>a[i]; } //sums[0]=a[0]; /*for(int i=1; i<n; i++){ sums[i]=sums[i-1]+a[i]; }*/ oldS=a[0]; ans=1; for(int i=1; i<n; i++){ int t=i; sum=0; while(sum<oldS && i<n){ sum+=a[i]; i++; } i--; while(oldS+a[t]<= sum-a[t]){ oldS+=a[t]; sum-=a[t]; t++; } if(sum>=oldS) ans++; oldS=sum; //cout<<i<<" "<<a[i]<<endl; } cout<<ans<<endl; } /* I wanna win a medal in IZHO If you watch shingeki no kyojin you can take my code */

Compilation message (stderr)

segments.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main(){
      |      ^
#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...