Weird Maths problem with Linear Programming? Here Again I am stuck with a problem.
We have a series which is sorted in ascending order. Every element in list is positive integer less than $10^9$.
Now, We are Given a positive integer $X$. (which will be used to do some weird calculations)
Our Target is to make all elements in list zero with X by following some rules.
Rule 1: At one time only one element in list can be changed.
Rule 2: For each operation either you can subtract $X$ to list element or just leave it.
Rule 3: if element in list is smaller than $X$ which is being changed $X$ becomes equal to that element.
Rule 4: After every Operation value of $X$ as well as Elements in list gets doubled. Notice here that the value of any element in list cannot exceed the original value at starting.

The answer is the minimum operations required to make all list elements zero.
Example to Understand with My approach

List : $10, 20, 30, 40, 50$
$X:1$
So, Now as we have $X = 1$ so we will need 4$ operations and in every operation value of $X$ will be doubled.<br>
$X = 8$, List : $10, 20, 30, 40, 50$. List elements doesn't changed as they cannot exceed thier initial value.
Now, on 5th operation X becomes 16. 
After this we have 2 ways, either i leave it & just double the X value or i change the X value to 10. 
Well i found few ways, If i just double the X until it becomes greater than Max element, then total operations were :
Total_Operations = (list_size - 1) + ceil(log2(Max/X))
which in this case comes out to be 10

But But. if i first did 4 operations by just doubling value of X, and in 5th operation i changed X into 10, then the answer changes.
As, when X becomes 10 we subtact X with 10 and one element becomes zero.
Now, X value doubles x becomes 20 so now 20 vanishes from list. 
then X doubles and becomes 40 and if we change X to 30 , 30 from list also vanishes..
Same happens with 40 and 50..
Finally we only require 9 total operations to make all elements zero.
I need to know if i am doing correct or any other more optimal solution exist. Please help.
 A: I finally solved the problem, and also created a C++ program that does the same work.
Concept, I used : 
So basically to understand this problem lets assume something related to real life to make it understand more easier. Lets Say we Have N countries each With some Population. We have been given their population in a sorted list  ( A1<=A2<=A3....<=An ). And as of Current Situation lets Say everyone in each country is infected with the virus(Corona Obviously), and a company has successfully made a cure that can cure anyone one time. But that person can get infected again. Now company can send Cure to only one country each day, however its on company to whom they want to give. Suppose they have X cures initially ready on Day 1, and the company creates double the cures that were delivered on previous day. One thing to note here is that if company created 5 cures on day i that on day i+1 it will create 10 cures, But lets say on day i+1 it delivered 7 cures only hence on next day it will make 14 cures not 20. Company cannot deliver more cures that population of any country. Means that if a country has 10 population company can send them any number of cures less than equal to 10. But this Corona virus is also not giving up, this means that after every day the infected people gets doubled.(But obviously they cant be more that total population of that country). We need to calculate the days required to make all countries corona virus free.
So, the Most optimal solution will be that we will find that Ai country to which we can reach in some days say K, and from that to last country we can calculate how many more days will be required lets Say M, and Now we Add i more to this sum as countries before Ai were skipped.
List : 1 20 110 
X = 10
Ans = 6
Explanation : 
Day 1: X = 10 , we can cure country 1 with population 1 fully but next day we will only be able to make 2 cures which are even less than today so we will skip it.
Day 2 : X = 20 , Now we can cure country 2 with population 20 fully and value of X also remains same. so new List : 1 0 110, X = 20
Day 3 : X = 40, Even if we send all cures to 3rd country on day 3 and cure 40 people, but on next day the remaining ones will infect all the cured ones again, as 110-40 = 70 > 40. 
Day 4 : X = 80, even now we cannot cure all people of country 3rd.

Day 5 : X = 160, Yes Now company is producing more cures than maximum value of list, now we can cure every country fully, so today country 3 will be cured, and on next day that is day 6 country 1 will be cured.
So, it took 6 days to optimally send cures to make world corona free.
I am new here, sorry for this boring explanation. it took me 2 days to solve this problem so i was excited to share my logic. :)
Now a C++ program that takes input N and X and then N space separated integers. and tells the minimum days that company will require to make world corona free.

