結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー ああいい
提出日時 2022-03-12 00:55:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 808 bytes
コンパイル時間 341 ms
コンパイル使用メモリ 82,024 KB
実行使用メモリ 109,084 KB
最終ジャッジ日時 2024-09-16 05:10:24
合計ジャッジ時間 5,539 ms
ジャッジサーバーID
(参考情報)
judge5 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 8 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())

def calc(A,B):

    N = len(A)
    now = A[0]
    right = 0
    for left in range(N):
        if A[right] > B[left]:
            return False
        if (left > 0 and A[left-1] == B[left]) or A[left] == B[left]:
            if right == left:
                right += 1
            continue
        while right < N and A[right] != B[left]:
            if A[right] > B[left]:
                return False
            right += 1
        if right == N:
            return False
        for j in range(left,right):
            A[j] = B[left]
        if right == left:
            right += 1
    return True

for _ in range(T):
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    if calc(A,B):
        print('Yes')
    else:
        print('No')
0