How to solve WARRIORS from Cook-off Aug'19?

During the contest, I could prove that it will work because (maximum \ power \ of \ a \ warrior \ = \ 10^9 ) * (maximum \ number \ of \ warriors \ = \ 10^5 ) = 10^{14} < 10^{15}. So, even if I don’t consider the gain in health we can get after fighting with every subsequent warrior, power of 10^{15} is large enough to kill all the remaining warriors.

As dragonemperor noted above, any number greater than or equal to twice the maximum power among all the warriors will work.

Change #if 0 to #if 1. Then also the code is failing. In the #else part, following two lines should be un-commented.

//x = size;
//break;

Still it is wrong. I need to know if the logic is correct or not.

Sorry, I got the issue in the code. Now it is giving TLE. I will try to optimize it.

Finally solved.

https://www.codechef.com/viewsolution/26083058