Submission #341581

#TimeUsernameProblemLanguageResultExecution timeMemory
341581katearimaBigger segments (IZhO19_segments)C++14
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> #define int long long 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]; } 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] && t<i){ 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:6:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    6 | 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...