I think I am failing test cases in this problem :
Where am I going wrong ?
.
.
.
My code :
I think I am failing test cases in this problem :
Where am I going wrong ?
.
.
.
My code :
lsp[i] = max(lsp[j]+1, lsp[j]);
This line
thanks for your reply, can you just brief it out?
Its should be
lsp[i] = max(lsp[j]+1, lsp[i]);
right? Just a typo
cuz max(x+1,x) is always x+1
oh god ! ya you just saved me thanks mate!
Could You Review my code also and tell whats wrong for same Question
It will be really helpful
Thanks in advance
if ( h[i] > x and iq[i] < y ) {
return 1 + rt(h,iq,i+1,n,h[i],iq[i] ) ;
}
Should be
if ( h[i] > x and iq[i] < y ) {
return max( rt(h,iq,i+1,n,x,y ) ,1 + rt(h,iq,i+1,n,h[i],iq[i] )) ;
}
But now it might go exponential so maybe memoize it.
Thanks Bro I got the case you explained
But still after doing correction it is giving me the wrong ans .
Here’s the link
for ( int i = 0 ; i < n ; i++ ) {
int h = v[i] ;
int iq = t[i] ;
curr = 1+rt(v,t,i+1,n,h,iq) ;
max_sub = max ( curr , max_sub ) ;
}
should be
for ( int i = 0 ; i + 1 < n ; i++ ) {
int h = v[i] ;
int iq = t[i] ;
curr = 1+rt(v,t,i+1,n,h,iq) ;
max_sub = max ( curr , max_sub ) ;
}
Can you please review my code…Thank you in advance, sir.
https://www.codechef.com/viewsolution/43034070