Submit | All submissions | Best solutions | Back to list |
EIEQUALS - Permutation |
Given two integer arrays a and b of length n and an integer k. Check if it is possible to turn array a into a permutation of b by selecting a number from a and changing it by no more than k units.
Input
The first line contains two positive integers n and k (1 ≤ n ≤ 105, 1 ≤ k ≤ 109).
The second line contains n positive integers a1, a2, …, an (1 ≤ ai ≤ 109).
The third line contains n positive integers b1, b2, …, bn (1 ≤ bi ≤ 109).
Output
In ra “YES” nếu có thể, ngược lại in ra “NO”.
Example
Input: 3 1 2 3 4 2 2 3 Output: NO Input: 3 2 2 3 4 2 2 3 Output: YES