Ladder
InterviewTime limit2sMemory limit64 MB
Given n sticks that can only be shortened, decide whether two can become length x and k others length y.
- Level
Medium4 of 10
- Topics
- Greedy, Sorting, Array, Implementation
- Solved
- No attempts yet
Problem
You have sticks of lengths . To build a ladder you need sticks: two sticks of length and sticks of length . You may shorten the sticks you have, but you cannot split one stick into two. Can you make a ladder?
Input
The first line contains a single integer , the number of test cases. The descriptions of the test cases follow.
Each test case consists of four integers , , , (, , ) followed by integers , , , ().
Output
For each test case, output a single line containing the word "YES" if making a ladder is possible, or "NO" otherwise.