PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#GD0000032. Sắp xếp lại hai mảng (Array Rearrangment)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Sắp xếp lại hai mảng (Array Rearrangment)
Array Rearrangment
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
Given arrays of length and an integer , you may permute each array. Determine whether they can be paired so that every pair sum is at most .
Input
The first line contains . The second and third lines contain and .
Output
Print Yes if possible, otherwise print No.
Constraints
- .
- .
- for .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): Full constraints.
Examples
Input
4 10
1 3 4 6
2 4 5 7
Output
Yes
Explanation
The sample follows the ordering rule described in the Vietnamese explanation and produces the shown optimum.