#abc364c. C - Minimum Glutton
C - Minimum Glutton
Score : points
问题陈述
有 道菜,第 道菜的甜度为 ,咸度为 。
高桥计划按照他喜欢的任何顺序排列这 道菜,并按该顺序吃。
他将按照排列的顺序吃菜,但一旦他吃过的菜的总甜度超过 或总咸度超过 ,他就会停止吃。
找出他最终会吃的最少的菜的数量。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are dishes, and the -th dish has a sweetness of and a saltiness of .
Takahashi plans to arrange these dishes in any order he likes and eat them in that order.
He will eat the dishes in the arranged order, but he will stop eating as soon as the total sweetness of the dishes he has eaten exceeds or the total saltiness exceeds .
Find the minimum possible number of dishes that he will end up eating.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
4 7 18
2 3 5 1
8 8 1 4
Sample Output 1
2
The -th dish will be denoted as dish .
If he arranges the four dishes in the order , as soon as he eats dishes and , their total sweetness is , which is greater than . Therefore, in this case, he will end up eating two dishes.
The number of dishes he will eat cannot be or less, so print .
Sample Input 2
5 200000000000000 200000000000000
1 1 1 1 1
2 2 2 2 2
Sample Output 2
5
Sample Input 3
8 30 30
1 2 3 4 5 6 7 8
8 7 6 5 4 3 2 1
Sample Output 3
6