|
||||||||||
magic ballsTime Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1826 Accepted Submission(s): 596 Problem Description The town of W has N people. Each person takes two magic balls A and B every day. Each ball has the volume $a_i$ and $b_i$. People often stand together. The wizard will find the longest increasing subsequence in the ball A. The wizard has M energy. Each point of energy can change the two balls¡¯ volume.($\text{swap}(a_i, b_i)$).The wizard wants to know how to make the longest increasing subsequence and the energy is not negative in last. In order to simplify the problem, you only need to output how long the longest increasing subsequence is. Input The first line contains a single integer $T(1 \leq T \leq 20)$(the data for $N > 100$ less than 6 cases), indicating the number of test cases. Each test case begins with two integer $N(1 \leq N \leq 1000)$ and $M(0 \leq M \leq 1000)$,indicating the number of people and the number of the wizard¡¯s energy. Next N lines contains two integer $a_i$ and $b_i(1 \leq a_i, b_i \leq 10^9)$,indicating the balls¡¯ volume. Output For each case, output an integer means how long the longest increasing subsequence is. Sample Input
Sample Output
Source | ||||||||||
|