At the cardboard box factory, boxes () are produced every day, each with a side length of (). In order to preserve the company's reputation, the stability of the boxes must be tested according to standard guidelines. The th guideline states that a tower with a minimum height of () must be achievable by stacking exactly boxes on top of one another. Each box is perfectly symmetrical, allowing them to be stacked onto of any other box, regardless of their size (a box of size 100 can be stacked on a box of size 1). Given the sizes of boxes, determine if it is possible to fulfil all guidelines.
Input Specifications
The first line will consist of a single integer , the number of boxes and number of guidelines.
The next line will consist of integers representing the size of the th box.
The last line will consist of integers representing the height requirement of the th guideline.
The height requirement of each guideline will be strictly greater than the previous. After all, what good is a smaller tower made with more boxes?
Output Specifications
Output Yes
if all guidelines can be fulfilled, output No
otherwise.
Subtasks
Subtask 1 [2/5]:
Subtask 2 [3/5]:
- No further constraints
Sample Input 1
3
3 2 5
1 5 7
Sample Output 1
Yes
Explanation for Sample Output 1
The first guideline can be fulfilled using any of the three boxes as the heights of any of the boxes are greater than 1.
The second guideline can be fulfilled by stacking either box 1 and box 2 for a height of 5, box 1 and box 3 for a height of 8, or box 2 and box 3 for a height of 7, all of which have have a height greater than 5.
The last guideline can be fulfilled stacking all three boxes for a total height of 10, a value larger than the required height of 7.
Sample Input 2
5
9 11 4 7 5
6 19 28 30 35
Sample Output 2
No
Explanation for Sample Output 2
It is impossible to achieve a tower of height 28 using only 3 boxes thus breaking the 3rd guideline.
Comments