Editorial for TLE '17 Contest 3 P4 - Meatballs
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
We will first solve the problem for general
Let
Note that if the
In fact, we can compute the probability that somebody ahead of the
There exists a formula for the probability that the
Thus,
For the first subtask, we manually compute the solutions by hand since there are not many of them.
For the second subtask, we perform the dynamic programming without any memoization.
For the third subtask, we perform
For the fourth subtask, we perform
For the last subtask, one can make an interesting note about the output from the previous subtasks and conjecture what the solution will be. It will not be posted here, since we don't want people copying this for free. Note however, that the formula can be proven.
Interesting fact: the pretests and samples of this problem all have an output of
Comments