아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Check Markers

시간 제한2초메모리 제한512 MB

요약
색깔별로 다 쓴 마커와 쓸 수 있는 마커의 개수가 주어질 때, 서로 다른 색의 쓸 수 있는 마커 두 개를 끝내 고르지 못하도록 할 수 있는지 판정한다.
난이도

보통10점 중 6점

유형
그리디, 수학, 구현, 정렬
정답자
아직 제출이 없습니다

문제

Alexander Markovich should start his lecture in five minutes, but at this moment he is just entering the university! He would be just in time unless it wasn't that the lecture had been scheduled in that huge room where lots of spent markers are all around. Now Alexander Markovich should find at least two markers of different colors that are not completely spent yet.

University professors use markers of nn different colors, and they are all in a single pile initially. We know that among the markers of color ii there are a_ia\_i spent and b_ib\_i good (that can still be used for writing) markers in the pile. It is impossible to distinguish whether a marker is spent or good by its appearance. In order to find two good markers of different colors, Alexander Markovich will repeat the following procedure:

  1. he takes two markers of different colors from the pile;
  2. then he simultaneously checks whether each of these markers can be used for writing;
  3. if both markers are good, Alexander Markovich takes them and starts the lecture;
  4. otherwise, if at least one of the markers is spent, he throws both markers to trash and returns to step 1.

Alexander Markovich chooses a pair of markers arbitrarily. Is it possible that he never finds two good markers of different colors, i. e. at some iteration of step 1 there are no two markers of different colors left in the pile?

You are to solve the problem for tt test cases.

입력

The first line contains a single integer tt (1≤t≤2⋅1051 \le t \le 2 \cdot 10^5) --- the number of test cases.

Each of the test cases is described in three lines. The first line contains a single integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10^5) --- the number of different colors of markers.

The second line of each test case contains  nn integers a_1a\_1, a_2a\_2, \ldots, a_na\_n (0≤a_i≤1090 \le a\_i \le 10^9) --- the number of spent markers of each color.

The third line of each test case contains nn integers b_1b\_1, b_2b\_2, \ldots, b_nb\_n (0≤b_i≤1090 \le b\_i \le 10^9) --- the number of good markers of each color.

It is guaranteed that the sum of nn over all test cases does not exceed 2⋅1052 \cdot 10^5.

출력

For each test case print "YES" in a separate line if it is possible that Alexander Markovich never finds two good markers of different colors, otherwise print "NO".

예제1

  1. 예제 1

    입력
    3
    3
    1 2 1
    2 1 1
    2
    1 1
    2 2
    4
    1 1 1 1
    2 1 2 1
    
    예상 출력
    YES
    NO
    YES