結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-11-26 23:45:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 728 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 120,004 KB
最終ジャッジ日時 2023-09-12 06:03:08
合計ジャッジ時間 5,981 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,952 KB
testcase_01 AC 86 ms
76,496 KB
testcase_02 AC 94 ms
76,668 KB
testcase_03 AC 87 ms
76,164 KB
testcase_04 AC 87 ms
76,448 KB
testcase_05 AC 91 ms
76,512 KB
testcase_06 AC 157 ms
98,656 KB
testcase_07 AC 157 ms
102,856 KB
testcase_08 AC 148 ms
96,376 KB
testcase_09 AC 146 ms
96,756 KB
testcase_10 AC 161 ms
107,132 KB
testcase_11 AC 169 ms
120,004 KB
testcase_12 AC 165 ms
119,752 KB
testcase_13 AC 168 ms
119,952 KB
testcase_14 AC 167 ms
119,744 KB
testcase_15 AC 165 ms
119,320 KB
testcase_16 AC 166 ms
116,112 KB
testcase_17 AC 169 ms
115,804 KB
testcase_18 AC 167 ms
115,792 KB
testcase_19 AC 163 ms
115,608 KB
testcase_20 AC 163 ms
115,880 KB
testcase_21 AC 73 ms
71,316 KB
testcase_22 AC 73 ms
71,396 KB
testcase_23 AC 90 ms
76,724 KB
testcase_24 WA -
testcase_25 AC 159 ms
116,000 KB
testcase_26 AC 158 ms
116,060 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

小さくはできない
小さいのは消せる
大きいのは消せない。



"""

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))
0