#P1478. 陶陶摘苹果(升级版)
陶陶摘苹果(升级版)
Description
It is autumn again, and the apple tree at TaoTao’s home has borne fruits. TaoTao goes to pick apples; this time he has a chair of height centimeters. When he cannot reach with his hand, he will stand on the chair and try again.
Different from the first problem of NOIp 2005 Junior: after moving the stool earlier, TaoTao has only strength left. Of course, each time he picks an apple, it costs some strength. TaoTao wants to know the maximum number of apples he can pick before .
Now you are given the heights above the ground of the apples , the chair height , TaoTao’s maximum reach , his remaining strength , and the strength needed to pick each apple . Find the maximum number of apples TaoTao can pick.
Input Format
Line 1: two numbers, the number of apples and the strength .
Line 2: two numbers, the chair height and TaoTao’s maximum reach .
Lines 3 to : each line contains two numbers, the apple height and the strength needed to pick this apple .
Output Format
Output a single integer, the maximum number of apples that TaoTao can pick.
8 15
20 130
120 3
150 2
110 7
180 1
50 8
200 0
140 3
120 2
4
Hint
For of the testdata, , , , , , .
Translated by ChatGPT 5
京公网安备 11011102002149号