Submission #493509

#TimeUsernameProblemLanguageResultExecution timeMemory
493509HomichkiBigger segments (IZhO19_segments)C++14
37 / 100
94 ms2680 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); //ifstream cin("input.txt"); //ofstream cout("output.txt"); ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol; vector<ll> a,b; vector<pair<ll,ll> > dp(3000); string s; char s1; cin>>n; for(i=0;i<n;i++) { cin>>x; a.push_back(x); } dp[0]={1,a[0]}; for(i=1;i<n;i++) { sum=0; for(j=i;j>=0;j--) { sum+=a[j]; if(j==0) { if(dp[i].first<1) { dp[i]={1,sum}; } } else { if((dp[j-1].first+1>dp[i].first) && (sum>=dp[j-1].second)) { dp[i]={dp[j-1].first+1,sum}; } else { if((dp[j-1].first+1==dp[i].first) && (sum<dp[i].second) && (sum>=dp[j-1].second)) { dp[i]={dp[i].first,sum}; } } } } } cout<<dp[n-1].first; return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:11:8: warning: unused variable 'k' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |        ^
segments.cpp:11:10: warning: unused variable 'm' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |          ^
segments.cpp:11:12: warning: unused variable 'x1' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |            ^~
segments.cpp:11:15: warning: unused variable 'y1' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |               ^~
segments.cpp:11:18: warning: unused variable 'p' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                  ^
segments.cpp:11:20: warning: unused variable 'qqq' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                    ^~~
segments.cpp:11:28: warning: unused variable 'z' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                            ^
segments.cpp:11:32: warning: unused variable 'y' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                ^
segments.cpp:11:34: warning: unused variable 'l' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                  ^
segments.cpp:11:36: warning: unused variable 'r' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                    ^
segments.cpp:11:38: warning: unused variable 'kry' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                      ^~~
segments.cpp:11:42: warning: unused variable 'w' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                          ^
segments.cpp:11:48: warning: unused variable 't' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                ^
segments.cpp:11:52: warning: unused variable 'h' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                    ^
segments.cpp:11:54: warning: unused variable 'mew' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                      ^~~
segments.cpp:11:58: warning: unused variable 'ma' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                          ^~
segments.cpp:11:61: warning: unused variable 'kol' [-Wunused-variable]
   11 |     ll k,m,x1,y1,p,qqq,i,j,z,x,y,l,r,kry,w,sum,t,n,h,mew,ma,kol;
      |                                                             ^~~
segments.cpp:15:10: warning: unused variable 's1' [-Wunused-variable]
   15 |     char s1;
      |          ^~
#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...