#P2248. 分段
分段
Description
You are given numbers , and you need to partition them into several contiguous segments, with the constraint that there are specified pairs of numbers that cannot be placed in the same segment.
The cost of creating one segment is:
where and are given constants, is the maximum value in that segment, and is the minimum value in that segment.
You need to find a partitioning scheme that minimizes the sum of costs over all segments.
Input Format
The first line contains two positive integers .
The second line contains two non-negative integers .
The third line contains non-negative integers .
Each of the next lines contains positive integers , indicating that cannot be in the same segment.
Output Format
Output a single line containing the minimum possible sum of the costs over all segments.
5 2
3 1
2 3 12 14 16
2 3
3 1
11
Hint
For of the testdata, .
For of the testdata, .
For another of the testdata, .
For another of the testdata, .
For of the testdata, , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号