Editorial for WC '16 Contest 2 J2 - EHC


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.

We should start by sorting all N existing holographic emitters in increasing order of distance from the mess hall. We can then iterate over them while maintaining the maximum distance d down the hall that the EHC is so far able to reach. d is initially equal to R, as there's an additional emitter at the entrance to the mass hall. When we consider emitter i, which covers the inclusive range from E_i-R to E_i+R, the EHC can already reach this range if d \ge E_i-R, in which case no additional emitters must be installed right before emitter i. Otherwise, there's an intervening distance of d' = E_i-R-D which must be filled in with emitters. Each emitter spans a distance of 2R metres, and so the additional emitters should be evenly spaced out at intervals of 2R metres in order to minimize the number of them that are required.

Therefore, \lceil \frac{d'}{2R} \rceil new emitters must be installed in order for the EHC to be able to reach emitter i. Either way, we can then set d to E_i+R and proceed to the next emitter. Finally, the EHC must still reach the end of the hallway from the end of the range of the furthest emitter. If we pretend that there's a dummy final emitter at a distance of M+R metres from the mess hall, then this is equivalent to the EHC reaching this dummy emitter, allowing the algorithm to avoid having any other final step.


Comments

There are no comments at the moment.