题目描述
Edward Elric is chasing after Scar. To stop Edward, Scar creates $N$ barriers in the way, numbered from $1$ to $N$.
Each barrier Scar created is either one of the following two types.
Type 1 barrier - This barrier starts from a height $X$ above the ground and extends till the sky.
Type 2 barrier - This barrier starts from the ground and extends up to height $X$ above the ground.
The height of Edward is $H$ units and he has an alchemic life force of $L$ units. Moreover, he can duck by $Y_{1}$ units and jump by height $Y_{2}$ units (as explained in the figures). He starts crossing barriers in sequence, starting from barrier $1$ till the barrier $N$. Whenever he can't pass a barrier by ducking or jumping (considered passed even when the barrier just touches him), he uses Alchemy to break the barrier. However, this costs him a single unit of his alchemic life force.
If after breaking a barrier no life force is left, Edward gets completely exhausted, unable to pass that barrier.
How many barriers can Edward cross?
And remember never to call him a pipsqueak if his height is too short!
------ Input: ------
The first line contains $T$, the number of test cases. Then the test cases follow.
For each test case, the first line contains five integers $N$, $H$, $Y_{1}$, $Y_{2}$ and $L$.
The i-th of the next $N$ lines contains two integers $t_{i}$ and $X_{i}$ for the $i^{th}$ barrier where $t_{i} = 1$ denotes a Type 1 Barrier and $t_{i} = 2$ denotes a Type 2 barrier.
------ Output: ------
For each test case print a single line containing the number of barriers Edward can pass.
------ Constraints ------
$1 ≤ T≤ 100$
$1 ≤ N≤ 10^{3}$
$2 ≤ H≤ 10^{3}$
$1 ≤ Y_{1} < H$
$1 ≤ Y_{2} ≤ 10^{3}$
$1 ≤ L ≤ N$
$1 ≤ t_{i} ≤ 2$
$1 ≤ X_{i}≤ 10^{3}$
----- Sample Input 1 ------
3
6 5 1 2 3
2 2
2 1
1 10
2 8
2 4
1 2
1 4 2 5 1
2 6
6 5 1 2 3
2 2
2 1
1 10
2 8
2 4
1 6
----- Sample Output 1 ------
5
0
6
----- explanation 1 ------
Test Case 1:
Given $N = 6$, $H = 5$, $Y_{1} = 1$, $Y_{2} = 2$ and $L = 3$.
He passes the first three barriers by either ducking or jumping. He uses alchemic life force for breaking $4^{th}$, $5^{th}$ and $6^{th}$ barriers because he cannot pass them by either jumping or ducking. He gets exhausted after breaking the $6^{th}$ barrier and is unable to pass it. So, in total he passes $5$ barriers.
输入格式
见题面
输出格式
见题面