Piles again doubt

Could you please send the solution for this , i have got AC in it but my solution fails for some test cases that i made

@debyian here look at this