EIEQUALS - Permutation

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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 ≤ 10^5, 1 ≤ k ≤ 10^9)~.
  • The second line contains ~n~ positive integers ~a_1, a_2, …, a_n~ ~(1 ≤ a_i ≤ 10^9)~.
  • The third line contains ~n~ positive integers ~b_1, b_2, …, b_n~ ~(1 ≤ b_i ≤ 10^9)~.

Output

  • In ra YES nếu có thể, ngược lại in ra NO.

Example Input 1

3 1
2 3 4 
2 2 3

Example Output 1

NO

Example Input 2

3 2
2 3 4 
2 2 3

Example Output 2

YES

Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.