Balls and Bins
시간 제한1초메모리 제한256 MB
각 bin의 현재 공 개수와 최대 용량이 주어질 때, 가득 찬 bin에서만 이동을 시작할 수 있다는 규칙으로 모든 공을 버릴 수 있는지 판정한다.
문제
Busy Beaver has bins and a large amount of balls. The -th bin can hold up to balls and currently contains balls. In a move, he first chooses a bin that is currently full (i.e., ). Then, for each ball in the chosen bin, he chooses to either discard it or move it to a different bin with enough space. (Within the same move, it is allowed to move different balls to different bins.)
Using only these moves, Busy Beaver is trying to remove all of the balls from all of the bins. Determine whether or not it is possible to do so.
입력
Each test contains multiple test cases. The first line of input contains a single integer , the number of test cases. The description of each test case follows.
The first line of each test case contains a single positive integer .
The second line contains integers --- the number of balls currently in each bin.
The third line contains integers --- the number of balls each bin can hold.
It is guaranteed that the sum of across all test cases does not exceed .
출력
For each test case, output "YES" (without quotes) if all bins may be emptied, and "NO" (without quotes) otherwise.
힌트
In the first test case, Busy Beaver can move all the balls in the first bin to the second bin. Then he will have exactly balls in the second bin, making the second bin full.
Then he can move all the balls from the second bin to the third bin. Then he will have exactly balls in the third bin, making the third bin full.
Finally, he can throw all the balls in the third bin away.
In the second test case, it can be shown that it is impossible to discard all the balls.