P23377 [AtCoder] [ABC364E] Maximum Glutton
普及+
题目描述

Problem Description

Takahashi has prepared $ N $ dishes for Snuke. Each dish is numbered from $ 1 $ to $ N $, and the sweetness of dish $ i $ is $ A_i $, and the saltiness is $ B_i $.

Takahashi can arrange these dishes in any order he likes. Snuke will eat the dishes in the order they are arranged. However, if at any point the total sweetness of the dishes eaten so far exceeds $ X $ or the total saltiness exceeds $ Y $, Snuke will not eat any more dishes.

Takahashi wants Snuke to eat as many dishes as possible. Determine the maximum number of dishes Snuke can eat when Takahashi arranges the dishes optimally.

Input Format

The input is given from the standard input in the following format:

$ N $ $ X $ $ Y $ $ A_1 $ $ B_1 $ $ A_2 $ $ B_2 $ $\vdots$ $ A_N $ $ B_N $

Output Format

Output the answer as an integer.

Sample Input and Output

Sample Input #1

4 8 4
1 5
3 2
4 1
5 3

Sample Output #1

3

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

Notes/Hints

Constraints

  • $1\leq\ N\ \leq\ 80$
  • $1\leq\ A_i,B_i\ \leq\ 10000$
  • $1\leq\ X,Y\ \leq\ 10000$
  • All inputs are integers

Sample Explanation 1

Consider Snuke's actions if Takahashi arranges the dishes in the order $ 2,3,1,4 $.
- First, Snuke eats dish $ 2 $. The total sweetness so far is $ 3 $, and the total saltiness is $ 2 $.
- Next, Snuke eats dish $ 3 $. The total sweetness so far is $ 7 $, and the total saltiness is $ 3 $.
- Then, Snuke eats dish $ 1 $. The total sweetness so far is $ 8 $, and the total saltiness is $ 8 $.
- Since the total saltiness exceeds $ Y=4 $, Snuke does not eat any more dishes.
Thus, in this arrangement, Snuke eats $ 3 $ dishes. Since no arrangement allows Snuke to eat all $ 4 $ dishes, the answer is $ 3 $.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 8 4 1 5 3 2 4 1 5 3
样例输出
3