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

Fall with Full Star

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 189    Accepted Submission(s): 53


Problem Description
Fall loves playing games and collecting strange achievements in games. If he doesn't pass a level with full stars, he will feel uncomfortable.

Today, Fall is playing a new game. The game includes $n$ levels without order, which means you can play the levels in any order. However, each level can only be challenged once. During the challenge, Fall may get hurt or pick up rare items. Assuming that before he challenges level $i$, he has power $x$, and after he challenges this level, his power will be increased by $d_i$. After that, if his power is higher than or equal to $s_i$, he will get a full star in this level.

Initially, Fall has power $s_0$ , he wants to find a challenge order that he can get full star levels as more as possible.

 

Input
The first line contains a single integer T ($1\leq T \leq 20$), the number of test cases. For each test case:

The first line contains two integers $n,s_0(1\leq n\leq 1\times 10^5,\sum{n}\leq 10^6, |s_0|\leq 10^{14})$.

The $i$-th line of the next $n$ lines contains two integers $d_i,s_i(|d_i|\leq 10^9,|s_i|\leq 10^{14})$, representing the information about the $i$-th level.
 

Output
For each test case, output a single line containing one integer -- the maximum number of full star levels that Fall can get in a single line.
 

Sample Input
1 3 0 4 5 2 5 1 100
 

Sample Output
2
 

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-26 00:15:22, Gzip enabled