Editorial for ICPC PACNW 2016 D - Contest Strategy


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

First, let's consider our expected penalty time, then multiply by n! to get the final answer. In this case, we can do "divisions" as multiplying by the inverse under the mod.

First, suppose we solve the problems in order i_1, i_2, \dots, i_n (i_k is the index of the k^\text{th} problem solved).

Then, the penalty time for this order can be written as:

\displaystyle t_{i_1} + (t_{i_1} + t_{i_2}) + \dots + (t_{i_1} + \dots + t_{i_n}) = n t_{i_1} + (n-1) t_{i_2} + \dots + 1 t_{i_n}

Let's apply linearity of expectation to this, so we can see that the contribution of a problem to the penalty time only depends on its position. Namely, if the expected value of the position of the i^\text{th} problem is E, this contributes (n-E) t_i to our penalty.

Let's sort our problems in increasing order of time (if there are ties, break them by index). It suffices to compute P_i → expected placement of the i^\text{th} problem. This can be computed with dp.

Now, once we fix a problem, we only care about how many problems are easier to solve and harder to solve. We should keep track of how many easier are unread, how many harder are unread, how many easier are read, how many harder are read, and whether or not we have read the problem we're interested in. This can be summarized as dp[i][j][k][l] → have i unread easier problems, have j unread harder problems, have k easier read problems, l = 1 if we have read the problem we're interested in and 0 otherwise (note that number of harder read can be derived from the above variables). We can write the transition rules based on the problem statement.

Of course, this dp takes \mathcal O(n^3) time to evaluate per position, which is too slow. Instead, we can note that a lot of the state is common across positions, so let's not reset the dp table in between positions. Thus, this shows that the total runtime is at most \mathcal O(n^3) over all n positions.


Comments

There are no comments at the moment.