Problem C
Porridge Boxes
Julia loves porridge. So much in fact, that if she had the possibility she would eat it all day, any day. However, due to a busy schedule, she does not have time to make porridge every day. But on days when she does have time to make porridge, she can make a big batch in her big pot that has room for $D$ daily servings. Luckily, Julia also has a refrigerator in her apartment so during the $N$ days when she actually can make a lot of porridge, she can store the leftover porridge in her refrigerator to eat on a day when she does not make porridge.
In order to remain happy, Julia needs to eat porridge at least $A$ of the $B$ days there are in total. How many daily servings of porridge does the refrigerator have to be able to store so that Julia can remain happy? If Julia makes porridge she always goes all-in and makes a full batch. If there isn’t room in the refrigerator for the leftovers from another batch, Julia can not make more porridge. (After all, if there’s anything Julia dislikes even more than being without porridge, it is food going to waste).
Input
The first line of input contains four space separated integers, $A$, $B$, $D$ and $N$ ($1 \leq A \leq B \leq 10^5$, $1 \leq D \leq 10^5$, $1 \leq N \leq 10^5$) Then follows $N$ space separated integers on a single line, signifying the index of the days that Julia has time to make porridge. The index for the days will start at index $0$.
Output
Print a single integer, the number of daily servings the refrigerator has to be able to store in order for Julia to eat porridge at least $A$ out of $B$ days. If it is not possible for Julia to eat porridge at least $A$ out of $B$ days, print impossible.
Grading
Group |
Point value |
Constraints |
$1$ |
$11$ |
$N \leq 10$ and $B \leq 1000$ |
$2$ |
$31$ |
$B \leq 1000$ |
$3$ |
$58$ |
No additional constraints. |
Sample Input 1 | Sample Output 1 |
---|---|
10 10 1 10 0 1 2 3 4 5 6 7 8 9 |
0 |
Sample Input 2 | Sample Output 2 |
---|---|
10 10 4 5 0 1 2 3 4 |
7 |
Sample Input 3 | Sample Output 3 |
---|---|
1000 1000 6000 1 0 |
5999 |
Sample Input 4 | Sample Output 4 |
---|---|
700 1000 600 1 0 |
impossible |