F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

magic balls

Time 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
2 5 3 5 1 4 2 3 1 2 4 3 1 5 4 5 1 4 2 3 1 2 4 3 1
 

Sample Output
4 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 16:16:46, Gzip enabled