题目描述
Problem Description
Takahashi, the eel, has a hobby of riding airplanes. This time, he has decided to travel back and forth between Airport A and Airport B.
It takes $ X $ hours to fly from Airport A to Airport B, and it takes $ Y $ hours to fly from Airport B to Airport A. There are $ N $ flights from Airport A to Airport B, and the $ i $th flight departs at $ a_i $ hours. There are $ M $ flights from Airport B to Airport A, and the $ j $th flight departs at $ b_j $ hours.
You can board a flight if you are at the departure airport before or exactly at the departure time. If you arrive exactly at the departure time, you can immediately board the flight and depart. Takahashi starts at Airport A at time $ 0 $. Determine the maximum number of round trips he can make between Airport A and Airport B.
Input Format
The input is given from the standard input in the following format:
$ N $ $ M $ $ X $ $ Y $ $ a_1 $ $ a_2 $ .. $ a_N $ $ b_1 $ $ b_2 $ .. $ b_M $
- The first line contains the number of flights from Airport A to Airport B, $N\ (\ 1\ ≦\ N\ ≦\ 10^5)$, and the number of flights from Airport B to Airport A, $M\ (\ 1\ ≦\ M\ ≦\ 10^5)$, separated by spaces.
- The second line contains the time it takes to fly from Airport A to Airport B, $X\ (\ 1\ ≦\ X\ ≦\ 10^9)$, and the time it takes to fly from Airport B to Airport A, $Y\ (\ 1\ ≦\ Y\ ≦\ 10^9)$, separated by spaces.
- The third line contains $ N $ integers representing the departure times of the flights from Airport A, $ a_i $, separated by spaces.
- The fourth line contains $ M $ integers representing the departure times of the flights from Airport B, $ b_j $, separated by spaces.
- It is guaranteed that $1\ ≦\ a_i\ ≦\ 10^9\ (1\ ≦\ i\ ≦\ N)$.
- It is guaranteed that $1\ ≦\ b_j\ ≦\ 10^9\ (1\ ≦\ j\ ≦\ M)$.
- It is guaranteed that $a_i\ <\ a_{i+1}\ (1\ ≦\ i\ ≦\ N-1)$.
- It is guaranteed that $b_i\ <\ b_{j+1}\ (1\ ≦\ j\ ≦\ M-1)$.
Output Format
Output the maximum number of round trips Takahashi can make between Airport A and Airport B in one line.
Do not forget the newline at the end of the output.
Sample Input and Output
Sample Input #1
3 4
2 3
1 5 7
3 8 12 13
Sample Output #1
2
Sample Input #2
1 1
1 1
1
1
Sample Output #2
0
Sample Input #3
6 7
5 3
1 7 12 19 20 26
4 9 15 23 24 31 33
Sample Output #3
3
Notes/Hints
Partial Points
This problem has partial points.
- For 30 points worth of test cases, it is guaranteed that $1\ ≦\ a_i\ ≦\ 10^5,\ 1\ ≦\ b_j\ ≦\ 10^5\ (\ 1\ ≦\ i\ ≦\ N,\ 1\ ≦\ j\ ≦\ M)$.
Sample Explanation 1
Board the flight departing from Airport A at 1 hour, arrive at 3 hours, and immediately board the flight departing from Airport B at 3 hours, arriving at Airport A at 6 hours. Next, board the flight departing from Airport A at 7 hours, arrive at 9 hours, and board the flight departing from Airport B at 12 hours, making a total of 2 round trips. There is no way to make 3 round trips.
Sample Explanation 2
If you go to Airport B, you cannot return to Airport A, so you cannot make any round trips.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分