Editorial for WC '16 Contest 4 S1 - Parking Duty
Submitting an official solution before solving the problem yourself is a bannable offence.
If no meters were to be skipped, then Judy's day would consist of "legs", with the -th leg consisting of travelling from coordinates to in seconds. The minimum top speed required to complete such a leg is simply the Euclidean distance of the leg divided by the time allowed for it. As such, the minimum top speed required for the entire day would be equal to the maximum of the legs' required top speeds.
In reality, the day will only have legs, as one meter will be skipped. If some meter is chosen to be skipped, aside from the first or last (such that ), then legs and will be removed and replaced by a new leg that travels directly from meter to (whose required top speed can be computed in the same way). If the first or last meter is skipped, then the first or last leg will instead be removed and not replaced with any new one.
At any rate, it can be observed that at most of the original legs can be removed, with the others staying as they are. Furthermore, if the original leg with the largest required top speed is the -th one (in the case of ties, can be any leg with the maximum required top speed), then in order to even have a chance of reducing the answer, the -th leg must be one of the ones removed. Therefore, once we determine the index (which can be done in time), we only need to consider skipping either meter or , and for each of those two options, we can afford to simulate the entire day with the given meter skipped in time, once again calculating the required top speeds of all legs present and taking the largest of them. Finally, the answer will be the smaller of the two required top speeds yielded by the two possibly optimal options.
Comments