2490: 【普及-】【P1478】 陶陶摘苹果(升级版)

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:1 解决:1

题目描述

又是一年秋季时,陶陶家的苹果树结了 lns="http://www.w3.org/1998/Math/MathML"> 个果子。陶陶又跑去摘苹果,这次他有一个 lns="http://www.w3.org/1998/Math/MathML"> 公分的椅子。当他手够不着时,他会站到椅子上再试试。

这次与 NOIp2005 普及组第一题不同的是:陶陶之前搬凳子,力气只剩下 lns="http://www.w3.org/1998/Math/MathML"> 了。当然,每次摘苹果时都要用一定的力气。陶陶想知道在 lns="http://www.w3.org/1998/Math/MathML"><0 之前最多能摘到多少个苹果。

现在已知 lns="http://www.w3.org/1998/Math/MathML"> 个苹果到达地上的高度 lns="http://www.w3.org/1998/Math/MathML">,椅子的高度 lns="http://www.w3.org/1998/Math/MathML">,陶陶手伸直的最大长度 lns="http://www.w3.org/1998/Math/MathML">,陶陶所剩的力气 lns="http://www.w3.org/1998/Math/MathML">,陶陶摘一个苹果需要的力气 lns="http://www.w3.org/1998/Math/MathML">,求陶陶最多能摘到多少个苹果。

输入

第 lns="http://www.w3.org/1998/Math/MathML">1 行:两个数 苹果数 lns="http://www.w3.org/1998/Math/MathML">,力气 lns="http://www.w3.org/1998/Math/MathML">

第 lns="http://www.w3.org/1998/Math/MathML">2 行:两个数 椅子的高度 lns="http://www.w3.org/1998/Math/MathML">,陶陶手伸直的最大长度 lns="http://www.w3.org/1998/Math/MathML">

第 lns="http://www.w3.org/1998/Math/MathML">3 行~第 lns="http://www.w3.org/1998/Math/MathML">3+1 行:每行两个数 苹果高度 lns="http://www.w3.org/1998/Math/MathML">,摘这个苹果需要的力气 lns="http://www.w3.org/1998/Math/MathML">

输出

只有一个整数,表示陶陶最多能摘到的苹果数。

样例输入 复制

8 15
20 130
120 3
150 2
110 7
180 1
50 8
200 0
140 3
120 2

样例输出 复制

4

提示

对于 lns="http://www.w3.org/1998/Math/MathML">100% 的数据,lns="http://www.w3.org/1998/Math/MathML">5000lns="http://www.w3.org/1998/Math/MathML">50lns="http://www.w3.org/1998/Math/MathML">200lns="http://www.w3.org/1998/Math/MathML">1000lns="http://www.w3.org/1998/Math/MathML">280lns="http://www.w3.org/1998/Math/MathML">100