bzoj#P1445. Pku3245 Sequence Partitioning
Pku3245 Sequence Partitioning
题目描述
Given a sequence of ordered pairs of positive integers , you have to partition it into several contiguous parts. Let be the number of these parts, whose boundaries are , which satisfy li = ri − 1 + 1, , ,. The parts themselves also satisfy the following estrictions:
-
For any two pairs , , where is belongs to the th part and the th part. If , then .
-
Let be the maximum of elements in the th part, say
$m_i = \max\{a_{l_i}, \cdots ,a_{r_i}\},1\leq i \leq p$
it is provided that
where is a given integer.
Let be the sum of of elements in the th part. Now I want to minimize the value
Could you tell me the minimum?
输入格式
The input contains exactly one test case.
The first line of input contains two positive integers .
Then follow lines each contains a positive integers pair . It's always guaranteed that $\max_{i=1}^n\{a_i\}\leq limit,\sum_{i=1}^n b_i\leq 2^{31}-1$。
输出格式
Output the minimum target value.
4 6
4 3
3 5
2 5
2 4
9
样例解释
An available assignment is the first two pairs are assigned into the first part and the last two pairs are assigned into the second part. Then $b_1>a_3,b_1>a_4,b_2>a_3,b_2>a_4,\max\{a_1,a_2\}+\max\{a_3,a_4\}\leq 6$, and minimum .
数据规模与约定
对于 的数据,,。