[ABC364E] 最大贪吃鬼 (Maximum Glutton)
Score : points
Problem Statement
Takahashi has prepared dishes for Snuke. The dishes are numbered from to , and dish has a sweetness of and a saltiness of .
Takahashi can arrange these dishes in any order he likes. Snuke will eat the dishes in the order they are arranged, but if at any point the total sweetness of the dishes he has eaten so far exceeds or the total saltiness exceeds , he will not eat any further dishes.
Takahashi wants Snuke to eat as many dishes as possible. Find the maximum number of dishes Snuke will eat if Takahashi arranges the dishes optimally.
Constraints
-
-
-
-
All input values are integers.
Input
The input is given from Standard Input in the following format:
$N$ $X$ $Y$
$A_1$ $B_1$
$A_2$ $B_2$
$\vdots$
$A_N$ $B_N$
Output
Print the answer as an integer.
Sample Input 1
4 8 4
1 5
3 2
4 1
5 3
Sample Output 1
3
Consider the scenario where Takahashi arranges the dishes in the order .
-
First, Snuke eats dish . The total sweetness so far is , and the total saltiness is .
-
Next, Snuke eats dish . The total sweetness so far is , and the total saltiness is .
-
Next, Snuke eats dish . The total sweetness so far is , and the total saltiness is .
-
The total saltiness has exceeded , so Snuke will not eat any further dishes.
Thus, in this arrangement, Snuke will eat three dishes.
No matter how Takahashi arranges the dishes, Snuke will not eat all four dishes, so the answer is .
Sample Input 2
2 1 1
3 2
3 2
Sample Output 2
1
Sample Input 3
2 100 100
3 2
3 2
Sample Output 3
2
Sample Input 4
6 364 463
230 381
154 200
328 407
339 94
193 10
115 309
Sample Output 4
3