五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(wǎng) 會員登陸 & 注冊

CF 1798A. Showstopper

2023-06-13 15:17 作者:您是打尖兒還是住店呢  | 我要投稿

You are given two arrays a1,a2,…,an and b1,b2,…,bn.In one operation, you can choose any integer i from 1 to n and swap the numbers ai and bi

.Determine whether, after using any (possibly zero) number of operations, the following two conditions can be satisfied simultaneously:

an=max(a1,a2,…,an),

bn=max(b1,b2,…,bn).

Here max(c1,c2,…,ck)

?denotes the maximum number among c1,c2,…,ck

. For example, max(3,5,4)=5, max(1,7,7)=7, max(6,2)=6

.Input

Each test contains multiple test cases. The first line contains the number of test cases t

?(1≤t≤200). The description of the test cases follows.

The first line of each test case contains a single integer n (1≤n≤100) — the length of the arrays.

The second line of each test case contains n integers a1,a2,…,an (1≤ai≤100) — elements of the first array.

The third line of each test case contains n integers b1,b2,…,bn (1≤bi≤100) — elements of the second array.

Output

For each test case, print "Yes" if after using any (possibly zero) number of operations the conditions described above are satisfied. Otherwise, print "No".

You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.

Example

input

7

3

7 9 7

7 6 9

4

10 10 15 15

10 16 15 15

2

100 99

99 100

1

1

1

9

1 2 3 4 5 6 7 8 9

9 9 9 9 9 9 6 6 6

7

1 1 2 2 1 1 2

1 2 1 2 1 2 1

2

30 4

5 30

output

Yes

No

Yes

Yes

Yes

No

No

Note

In the first test case, you can swap the numbers a3 and b3, after which the array a becomes equal to [7,9,9], and the array b becomes equal to [7,6,7], and both conditions are met.

In the second test case, it can be proved that it is impossible to satisfy both conditions.

In the third test case, you can swap the numbers a1 and b1, after which the array a

?becomes equal to [99,99], and the array b becomes equal to [100,100], and both conditions are satisfied.

In fifth test case, you can swap a7 and b7, a8 and b8, a9 and b9, after which the array a

?becomes equal to [1,2,3,4,5,6,6,6,6], and the array b becomes equal to [9,9,9,9,9,9,7,8,9]

, and both conditions are satisfied.

就是說給定2個數(shù)組,想確認能否通過交換數(shù)組對應(yīng)的位置,使得數(shù)組的最后1個數(shù)字就是這個數(shù)組的最大值,如果可以,輸出yes,如果不可以,輸出no;

思路是把所有對應(yīng)數(shù)字中小的數(shù)字放一個數(shù)組中,大的數(shù)字放到另一個數(shù)組中,去判斷最后一個數(shù)字是否是該數(shù)組的最大值,如果是則返回yes,不是則返回no

下面是代碼:


CF 1798A. Showstopper的評論 (共 條)

分享到微博請遵守國家法律
竹山县| 泸水县| 白河县| 丰都县| 丹阳市| 海城市| 隆回县| 固阳县| 图木舒克市| 华坪县| 梅州市| 壶关县| 临高县| 大化| 桦甸市| 长汀县| 高尔夫| 育儿| 无锡市| 厦门市| 南丰县| 镇宁| 武功县| 漳州市| 安达市| 浑源县| 怀集县| 都安| 察哈| 鄂尔多斯市| 加查县| 沂水县| 榕江县| 临猗县| 锦州市| 清新县| 调兵山市| 尼勒克县| 鹿邑县| 武夷山市| 双鸭山市|