Can you tell my mistake?

what is your doubt in this?

for which input you are facing problem?

It is not giving any output only. In one compiler segmentation fault is coming while in the other there is no output.

@vageesha for which input ??

for me it’s working

for:
10 2 20 -1 -1 1 -1 -1 10 -25 3 -1 -1 4 -1 -1

input is not correct

you have to put one more -1 at end
check again

after that it will give correct ans

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.