Facing runtime error in savkono problem

problem : CodeChef: Practical coding for everyone
solution : CodeChef: Practical coding for everyone

I used heap data structure.
First I built max heap on array of attacking power of soldiers then
each time I subtracted z by max(arr[0]) and reduced max by half and heapify, I contunued this process untill z <= 0, I am getting correct result on manual input, but while submit, it gives run time error.

solved

well done