#1445. Pku3245 Sequence Partitioning

Pku3245 Sequence Partitioning

题目描述

Given a sequence of nn ordered pairs of positive integers (ai,bi)(a_i,b_i), you have to partition it into several contiguous parts. Let pp be the number of these parts, whose boundaries are (l1,r1),(l2,r2),,(lp,rp)(l_1, r_1), (l_2, r_2), \cdots ,(l_p, r_p), which satisfy li = ri − 1 + 1, liril_i\leq r_i, l1=1l_1 = 1,rp=nr_p = n. The parts themselves also satisfy the following estrictions:

  1. For any two pairs (ap,bp)(a_p, b_p), (aq,bq)(a_q, b_q), where (ap,bp)(a_p, b_p) is belongs to the tpt_p th part and (aq,bq)(a_q, b_q) the tqt_q th part. If tp<tqt_p<t_q, then bp>aqb_p>a_q.

  2. Let mim_i be the maximum A-componentA\text{-component} of elements in the ii th part, say

    $m_i = \max\{a_{l_i}, \cdots ,a_{r_i}\},1\leq i \leq p$

    it is provided that

    i=1pmilimit\sum_{i=1}^p m_i\leq limit

    where limitlimit is a given integer.

Let sis_i be the sum of B-componentsB\text{-components} of elements in the ii th part. Now I want to minimize the value

max{si:1ip}\max\{s_i:1\leq i \leq p\}

Could you tell me the minimum?

输入格式

The input contains exactly one test case.

The first line of input contains two positive integers n,limitn,limit.

Then follow nn lines each contains a positive integers pair (a,b)(a,b). 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 max{b1+b2,b3+b4}=9\max\{b_1+b_2, b_3+b_4\}=9.

数据规模与约定

对于 100%100\% 的数据,1n5×1041\leq n\leq 5\times 10^4limit2311limit\leq 2^{31}-1