Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Language: Sequence Partitioning
Description Given a sequence of N ordered pairs of positive integers (Ai, Bi), you have to partition it into several contiguous parts. Let p be the number of these parts, whose boundaries are (l1, r1), (l2, r2), ... ,(lp, rp), which satisfy li = ri − 1 + 1, li ≤ ri, l1 = 1, rp = n. The parts themselves also satisfy the following restrictions:
Let Si be the sum of B-components of elements in the ith part. Now I want to minimize the value max{Si:1 ≤ i ≤ p} Could you tell me the minimum? Input The input contains exactly one test case. The first line of input contains two positive integers N (N ≤ 50000), Limit (Limit ≤ 231-1). Then follow N lines each contains a positive integers pair (A, B). It's always guaranteed that max{A1, A2, ..., An} ≤ LimitOutput Output the minimum target value. Sample Input 4 6 4 3 3 5 2 5 2 4 Sample Output 9 Hint 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 B1 > A3, B1 > A4, B2 > A3, B2 > A4, max{A1, A2}+max{A3, A4} ≤ 6, and minimum max{B1+B2, B3+B4}=9. Source POJ Monthly--2007.07.08, Chen, Danqi |
[Submit] [Go Back] [Status] [Discuss]
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator