Picking flowers - MarisaOJ: Marisa Online Judge

Picking flowers

Time limit: 1000 ms
Memory limit: 256 MB
On a field of flowers lies a coordinate axis with n blooming flowers. The ith flower is located at position xi and takes ti minutes to pick. These flowers will wither when it starts raining. It is known that it will rain after m minutes. Marisa starts at position 0. Each minute, she can move one unit of distance. How many flowers can Marisa pick optimally? She can choose to skip picking certain flowers. ### Input - The first line contains two integers n and m. - The next n lines each contain two integers xi and ti. ### Output - Output a single integer representing the maximum number of flowers Marisa can pick. ### Constraints - 1≤n≤2×105. - 1≤m,xi,ti≤109. It is guaranteed that the values of xi are distinct for all i's. ### Example Input: 2121100066 Output: 1