Cover the Demands
Each worker has a capacity (array A) and each task a demand (array B); a worker can take one task with demand ≤ capacity. Can all N tasks be assigned to the N workers?
Input: the first line has N; the second line has the N capacities; the third line has the N demands.
Output: YES or NO.
Constraints:
- 1 ≤ N ≤ 105
- |values| ≤ 109
Sample Tests
Input 1
3 3 5 2 2 2 4
Output 1
YES
Input 2
2 1 1 1 2
Output 2
NO
Discussion (opens after you solve — no spoilers before)
No comments yet.