結果

問題 No.1768 The frog in the well knows the great ocean.
ユーザー tktk_snsntktk_snsn
提出日時 2021-11-26 23:44:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 862 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 10,860 KB
実行使用メモリ 37,832 KB
最終ジャッジ日時 2023-09-12 06:02:52
合計ジャッジ時間 5,007 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
8,652 KB
testcase_01 AC 24 ms
8,716 KB
testcase_02 AC 25 ms
8,848 KB
testcase_03 AC 24 ms
8,756 KB
testcase_04 AC 24 ms
8,760 KB
testcase_05 AC 23 ms
8,760 KB
testcase_06 AC 155 ms
22,948 KB
testcase_07 AC 151 ms
25,112 KB
testcase_08 AC 147 ms
23,052 KB
testcase_09 AC 135 ms
21,080 KB
testcase_10 AC 149 ms
25,900 KB
testcase_11 AC 174 ms
27,472 KB
testcase_12 AC 171 ms
27,528 KB
testcase_13 AC 161 ms
27,468 KB
testcase_14 AC 143 ms
27,540 KB
testcase_15 AC 159 ms
27,624 KB
testcase_16 AC 196 ms
37,832 KB
testcase_17 AC 199 ms
37,772 KB
testcase_18 AC 197 ms
37,808 KB
testcase_19 AC 159 ms
37,728 KB
testcase_20 AC 163 ms
37,820 KB
testcase_21 AC 18 ms
8,660 KB
testcase_22 AC 19 ms
8,616 KB
testcase_23 AC 21 ms
8,668 KB
testcase_24 WA -
testcase_25 AC 160 ms
36,316 KB
testcase_26 AC 132 ms
36,236 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


def RunLengthEncoding(S):
    res = []
    N = len(S)
    i = 0
    while i < N:
        cnt = 1
        while i < N - 1 and S[i] == S[i + 1]:
            cnt += 1
            i += 1
        res.append(S[i])
        i += 1
    return res


def F(N, A, B):
    if not set(A).issuperset(set(B)):
        return False
    for i in range(N):
        if A[i] > B[i]:
            return False

    i = 0
    for b in B:
        while i < N and b != A[i]:
            i += 1
        if i >= N:
            return False
    return True


T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))[::-1]
    B = list(map(int, input().split()))[::-1]
    if F(N, A, B):
        print("Yes")
    else:
        print("No")
0