Logo
(追記) (追記ここまで)

21635번 - Check Markers 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB78302740.299%

문제

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 $n$ different colors, and they are all in a single pile initially. We know that among the markers of color $i$ there are $a_i$ spent and $b_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 $t$ test cases.

입력

The first line contains a single integer $t$ (1ドル \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 $n$ (2ドル \le n \le 2 \cdot 10^5$) --- the number of different colors of markers.

The second line of each test case contains $n$ integers $a_1,ドル $a_2,ドル \ldots, $a_n$ (0ドル \le a_i \le 10^9$) --- the number of spent markers of each color.

The third line of each test case contains $n$ integers $b_1,ドル $b_2,ドル \ldots, $b_n$ (0ドル \le b_i \le 10^9$) --- the number of good markers of each color.

It is guaranteed that the sum of $n$ over all test cases does not exceed 2ドル \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

3
3
1 2 1
2 1 1
2
1 1
2 2
4
1 1 1 1
2 1 2 1

예제 출력 1

YES
NO
YES

힌트

출처

Olympiad > Russian Olympiad in Informatics > Russia Team High School Programming Contest > Russia Team High School Programming Contest 2020 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /