#K86577. Tanya's Flower Growth
Tanya's Flower Growth
Tanya's Flower Growth
Tanya has N flower seeds, where each seed is associated with two parameters: the daily water requirement Ai and the days to blossom Bi. Although the blossom time is provided, it is not relevant to the water allocation strategy.
Given a total daily water supply W, Tanya wants to maximize the number of different flower types she can grow. She follows a greedy strategy: she selects the seeds with the lowest water requirement first. Formally, if she selects k seeds with water requirements A1, A2, \dots, Ak (after sorting in non-decreasing order), the selection is valid if
$$\sum_{i=1}^{k} A_i \le W.$$
Your task is to compute the maximum number of flower types that Tanya can grow under these conditions.
inputFormat
The first line contains two integers N and W separated by a space, where N is the number of flower seeds and W is the total daily water available.
Each of the next N lines contains two integers A and B separated by a space, representing the water requirement per day and the number of days to blossom for that flower, respectively.
outputFormat
Output a single integer representing the maximum number of flower types Tanya can grow.
## sample4 10
4 2
3 3
5 4
2 1
3