You have initial power x and have n enemies from 1 to n with power equal to array[i]…
You can kill only 1 enemy in one day and if your power is less than enemy power…enemy power fill again be restored to original power …but your power after every blow to a enemy will double…you can only give a single blow to your any one enemy every day
However after killing that enemy your power will become 2wice that of enemy power and next day this will be your starting power…
Output the min no of days to kill all enemies…
Eg n=6. X=7
10 20 30 50 200 40
Output expected:8 days
Explanation: you can decide to kill first enemy having power 10…
It will take you 2 days to kill him as first day you can give a blow of 7 and next day since your power doubles … therefore you can strike your enemy.(whose power will become original if he is not killed properly) with blow of 14 which will kill him as his new power was 10 …now your power will be 20 for next day as you have killed him…
Then you can directly kill enemy with power 20 in 1 day…as you have power 20…
Then you can strike the partner with power 40 in 1 day as your power will be 40 …after killing your power will be doubled to 80 …
You can killl then 200 peer enemy in 3 moves and then you can target 50 and 30 power enemies …in one days each respectively…
Therefore total days will be 8 days…and this will be min ans …
Note :Many other configurations of killing might give the same result…fir example if you start by trying to kill 20 power enemy right at the start …
array may contain duplicates as well…