問題一覧 > 通常問題

No.1768 The frog in the well knows the great ocean.

レベル : / AI推定難易度 : 1950 / 実行時間制限 : 1ケース 3.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 48
作問者 : first_vil / テスター : chineristAC ygussany
お気に入りにしたユーザー ProblemId : 7211 / 自分の提出
問題文最終更新日: 2021-11-26 14:45:22
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 325 (順位表) の他の問題:

Note

The time limit for this problem is $3$ seconds.

Problem Statement

You are given sequences $A,B$ of length $N$. Determine whether $A$ can be made equal to $B$ by performing the following operation $0$ or more times.

  • Choose integers $l,r\ (1 \le l \le r \le N)$ and replace all of $A_l,A_{l+1},\dots,A_r$ with their maximum value.

You are given $T$ test cases; find the answer for each of them.

Input

$T$
$case_1$
$case_2$
$\vdots$
$case_T$

Each test case is given in the following format.

$N$
$A_1$ $A_2$ $\dots$ $A_N$
$B_1$ $B_2$ $\dots$ $B_N$
  • All input values are integers.
  • $1 \le T \le 2 \times 10^5$
  • $1 \le N \le 2 \times 10^5$
  • $1 \le A_i,B_i \le N$
  • In $1$ input file, the sum of $N$ does not exceed $2 \times 10^5$.

Output

Output $T$ lines.

On line $i\ (1 \le i \le T)$, for the $i$-th test case, output Yes if $A$ can be made equal to $B$, and No otherwise, followed by a newline.

Sample

Sample 1
Input
4
2
2 1
2 2
4
2 1 2 2
2 2 2 1
5
1 3 1 2 3
3 3 4 4 4
7
2 4 1 6 2 2 1
2 6 6 6 6 2 2
Output
Yes
No
No
Yes

In test case $1$, the sequences can be made equal by performing the operation with $(l,r)=(1,2)$.

In test cases $2,3$, the sequences cannot be made equal no matter how the operations are performed.

In test case $4$, the sequences can be made equal by performing the operations $(l,r)=(5,7),(l,r)=(2,5)$ in this order.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。