For the Problem C, I was trying to use the below strategy.
First count m days in the answer, since rate of replenishing the stock is greater than the rate of consumption. After that, for the next day, the number of grains left would be
n-m-1
for the next to next day, the grains left would be
n-m-1-2
and so on.
At the last, we get
x^2 + x -2n + 2m >= 0
where x is the number of days required. But using this strategy fails.
All the solutions that I saw were using binary search. Has somebody use similar technique in their solutions or can someone point out mistake in doing this way?