Submission #339523

#TimeUsernameProblemLanguageResultExecution timeMemory
339523scalesBigger segments (IZhO19_segments)C++17
0 / 100
1 ms364 KiB
#include <bits/stdc++.h> /*#ifndef LOCAL_RUN #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC target("avx2,tune=native") #endif*/ using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p; cin>>n; vector<long long> a(n); for(i=0;i<n;i++) { cin>>a[i]; } kol=1; l=1; r=1; p=a[0]; sum=0; while(r!=n) { //cout<<"l="<<l<<" r="<<r<<endl; while(sum<p && r!=n) { sum=sum+a[r]; r++; } if(sum<p) { break; } else { kol++; while(sum-2*a[l]>=p) { sum=sum-a[l]; p=p+a[l]; l++; } p=sum; sum=0; l=r; } } cout<<kol<<endl; return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:15:16: warning: unused variable 't' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                ^
segments.cpp:15:20: warning: unused variable 'j' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                    ^
segments.cpp:15:22: warning: unused variable 'w' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                      ^
segments.cpp:15:24: warning: unused variable 'dno' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                        ^~~
segments.cpp:15:28: warning: unused variable 'mini' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                            ^~~~
segments.cpp:15:37: warning: unused variable 'x' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                     ^
segments.cpp:15:39: warning: unused variable 'y' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                       ^
segments.cpp:15:41: warning: unused variable 'z' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                         ^
segments.cpp:15:43: warning: unused variable 'q' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                           ^
segments.cpp:15:45: warning: unused variable 'm' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                             ^
segments.cpp:15:51: warning: unused variable 'k' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                   ^
segments.cpp:15:53: warning: unused variable 'v' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                     ^
segments.cpp:15:61: warning: unused variable 'x1' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                             ^~
segments.cpp:15:64: warning: unused variable 'tip' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                                ^~~
segments.cpp:15:68: warning: unused variable 'g' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                                    ^
segments.cpp:15:70: warning: unused variable 'maxi' [-Wunused-variable]
   15 |      long long t,i,j,w,dno,mini,sum,x,y,z,q,m,l,r,k,v,n,kol,x1,tip,g,maxi,p;
      |                                                                      ^~~~
#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...