My code only works for sample test case

when i submit it wont pass any test cases, can you check and edit my code.
i exactly implemented from editorial.

https://www.codepile.net/pile/lJVlD3L3

@premang do not calculate max of inc[i] and dec[i] separately instead you should calculate ans as max(ans, inc[i]+dec[i]-1) in a single for loop.