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
Added by: | Ha Minh Ngoc |
Date: | 2019-04-16 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |