結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー ああいい
提出日時 2022-03-12 00:56:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 807 bytes
コンパイル時間 313 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 108,952 KB
最終ジャッジ日時 2024-09-16 05:10:56
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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[left] > 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