結果
| 問題 | No.1768 The frog in the well knows the great ocean. | 
| コンテスト | |
| ユーザー | 👑  SPD_9X2 | 
| 提出日時 | 2021-11-26 23:45:41 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 728 bytes | 
| コンパイル時間 | 155 ms | 
| コンパイル使用メモリ | 81,968 KB | 
| 実行使用メモリ | 115,044 KB | 
| 最終ジャッジ日時 | 2024-06-29 19:07:50 | 
| 合計ジャッジ時間 | 4,084 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 25 WA * 2 | 
ソースコード
"""
小さくはできない
小さいのは消せる
大きいのは消せない。
"""
import sys
from sys import stdin
tt = int(stdin.readline())
ANS = []
for loop in range(tt):
    N = int(stdin.readline())
    A = list(map(int,stdin.readline().split()))
    B = list(map(int,stdin.readline().split()))
    flag = True
    for i in range(N):
        if A[i] > B[i]:
            flag = False
    B2 = []
    for i in B:
        if len(B2) == 0 or B2[-1] != i:
            B2.append(i)
    for i in range(N-1,-1,-1):
        if len(B2) > 0 and B2[-1] == A[i]:
            del B2[-1]
    if B2:
        flag = False
    if flag:
        ANS.append("Yes")
    else:
        ANS.append("No")
print ("\n".join(ANS))
            
            
            
        