Editorial for DMOPC '21 Contest 2 P4 - Water Mechanics
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Subtask 1
For this subtask, the simplest solution is probably, for all indices dp[i]
where dp[i]
represents the minimum cost such that the first
Time Complexity:
Subtask 2
We can extend the previous solution. We need to calculate
With these intervals, we can do two things. The first is to run a greedy solution where we take the interval with the farthest right point that still covers the leftmost uncovered cell, which works because the intervals are monotonically sorted by both
Time Complexity:
Comments
Quick question I see how the greedy method works but can someone explain the segment tree method to me? tysm!