The Ravagers' Treasure Hunt

hard
The Ravagers, a group of space mercenaries, have discovered information about several treasure vaults across the galaxy. Yondu needs to assign his crew members to raid these vaults efficiently.
There are nn treasure vaults and mm crew members. Each vault has a security level represented in a 00-indexed integer array vv, with the ithi^{th} vault requiring viv_i skill to break into. The skill level of each crew member is stored in a 00-indexed integer array rr, with the jthj^{th} crew member having rjr_j skill level. Each crew member can only be assigned to a single vault and must have a skill level greater than or equal to the vault's security level (i.e., rjvir_j \geq v_i).
Yondu also has bb special tech boosters that will increase a crew member's skill by ee. He can decide which crew members receive these boosters; however, each crew member may receive at most one booster.
Given the 00-indexed integer arrays vv and rr and the integers bb and ee, return the maximum number of vaults that can be raided.

Input Format:

The first line of input contains two integers nn and mm (1n105(1 \leq n \leq 10^5 and 1m105)1 \leq m \leq 10^5), the number of vaults and ravagers respectively. The second line contains two integers: the number of bb (0bm)(0 \leq b \leq m) and ee (1e109)(1 \leq e \leq 10^9). The third line contains nn integers v1,v2,,vnv_1, v_2, \dots, v_n representing the vaults. (1vi<109)(1 \leq v_i < 10^9) The fourth line contains mm integers r1,r2,,rmr_1, r_2, \dots, r_m representing the ravagers. (1ri109)(1 \leq r_i \leq 10^9)

Output Format:

Output a single integer representing the maximum number of vaults that can be raided.

Examples:

Example 1:

Input:

3 3
1 1
3 2 1
0 3 3

Output:

3

Example 2:

Input:

2 3
1 5
5 4
0 0 0

Output:

1

Code

Loading Editor...