Box Packing
Time limit1sMemory limit256 MB
Given n boxes as ordered pairs, select the most boxes that can be split into at most k chains, where each chain is nondecreasing in both coordinates.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Sorting, Greedy, Binary search
- Solved
- No attempts yet
Problem
An ordered pair of integers is called a box. A sequence of boxes is called a chain if the following inequalities hold:
You are given boxes: . Find the maximum number of boxes you can select from them and split into no more than chains. You can reorder the boxes to form chains.
Input
The first line contains two integers, and (, ).
The -th of the following lines contains two integers, and ().
Output
Print one integer: the answer.