### PROBLEM LINK:

**Author:** Sidhant Bansal

**Testers:** Hasan Jaddouh

**Editorialist:** Sidhant Bansal

### DIFFICULTY:

easy

### PREREQUISITES:

basic math

### PROBLEM:

In this problem, the greedy approach of buying the box of chocolate for some consecutive early days is the right direction.

Let A = K * S and B = N * (S - S/7), here A denotes the total number of chocolates we need to eat and B denotes the maximum no. of chocolates we can buy. Here S - S/7 denotes the number of days the shop is open.

So if A > B or ((N - K) * 6 < K and S \geq 7), then the answer is -1.

otherwise the answer is ceil(\frac{A}{N}), where ceil(x) denotes ceiling function on x.

The first condition i.e A > B, for -1 is fairly obvious that if the total no. of chocolates we need to eat is more than we can buy at max then it is invalid.

The second condition i.e (N - K) * 6 < K and S \geq 7 is a bit tricky, it is basically the contrapositive of the statement, “if you can survive the first 7 days, then you can survive any given number of days”. So the contrapositive (i.e same statement in different words) is "if you cannot survive the first 7 days then you won’t be able to survive for S \geq 7". The condition for being able to survive on the 7^{th} day is basically if we add our remaining chocolates from the first 6 days, i.e (N - K) * 6 and it is still smaller than K, i.e the chocolates we need for the 7^{th} day, then we don’t survive. But we only need to test this when S \geq 7.

Incase, we are able to survive, then the answer is ceil(\frac{A}{N}), which is basically total number of chocolates we need to eat divided by the number of chocolates we can buy in a single day (and if a remainder exists, then we need to buy one more day). This portion is pretty straightforward.

The above reasoning to check for -1 is obviously tricky and a simpler approach exists which is to just simulate the days once we know the value of ceil(\frac{A}{N}).