Submission #339521

#TimeUsernameProblemLanguageResultExecution timeMemory
339521scalesBigger 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); int 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-2*a[l]; l++; } p=sum; sum=0; } } cout<<kol<<endl; return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:15:10: warning: unused variable 't' [-Wunused-variable]
   15 |      int 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:14: warning: unused variable 'j' [-Wunused-variable]
   15 |      int 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:16: warning: unused variable 'w' [-Wunused-variable]
   15 |      int 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:18: warning: unused variable 'dno' [-Wunused-variable]
   15 |      int 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 'mini' [-Wunused-variable]
   15 |      int 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:31: warning: unused variable 'x' [-Wunused-variable]
   15 |      int 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:33: warning: unused variable 'y' [-Wunused-variable]
   15 |      int 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:35: warning: unused variable 'z' [-Wunused-variable]
   15 |      int 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 'q' [-Wunused-variable]
   15 |      int 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 'm' [-Wunused-variable]
   15 |      int 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 'k' [-Wunused-variable]
   15 |      int 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:47: warning: unused variable 'v' [-Wunused-variable]
   15 |      int 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:55: warning: unused variable 'x1' [-Wunused-variable]
   15 |      int 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:58: warning: unused variable 'tip' [-Wunused-variable]
   15 |      int 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:62: warning: unused variable 'g' [-Wunused-variable]
   15 |      int 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 'maxi' [-Wunused-variable]
   15 |      int 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...