You are given an integer sequence of length and intervals . Here, satisfy , and each integer between and appears once as an end of an interval.
Your goal is to create a set of intervals to satisfy at least one of the following conditions for all .
- There exists an integer () such that and .
The cost of the set is defined as follows.
- The sum of for all intervals included in .
Find the minimum cost of the set that satisfies the condition.