Editorial for TLE '16 Contest 5 P3 - Flight Exam
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
First, we note that there are up to significant points that Fax can visit: all
checkpoints, and all points that are
meters below a checkpoint. If
or the point has a negative altitude, we ignore the second point. For each point, we store the number of checkpoints Fax gains if he passes through this point. As such, each point will either have a value of
(checkpoint with nothing above, empty point with checkpoint above) or
(checkpoint with checkpoint above). For the
point, let this value be
.
Next, we can use dynamic programming to compute the answer. For each point, we want to know the maximum number of checkpoints Fax could have passed through after going through the current point and performing a loop. For the point, let this value be
. We can see that
for all points
with a distance less than point
that can be reached by ascending or descending.
The answer is the maximal .
Time Complexity:
Comments