結果

問題 No.2518 Adjacent Larger
ユーザー 👑 rin204rin204
提出日時 2023-10-27 21:36:10
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 2,000 ms
コード長 512 bytes
コンパイル時間 141 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 98,072 KB
最終ジャッジ日時 2023-10-27 21:36:14
合計ジャッジ時間 3,325 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,556 KB
testcase_01 AC 146 ms
76,936 KB
testcase_02 AC 141 ms
77,164 KB
testcase_03 AC 138 ms
77,164 KB
testcase_04 AC 136 ms
76,904 KB
testcase_05 AC 136 ms
77,144 KB
testcase_06 AC 82 ms
76,080 KB
testcase_07 AC 93 ms
76,132 KB
testcase_08 AC 81 ms
76,120 KB
testcase_09 AC 81 ms
76,120 KB
testcase_10 AC 80 ms
76,132 KB
testcase_11 AC 45 ms
67,948 KB
testcase_12 AC 44 ms
69,996 KB
testcase_13 AC 42 ms
67,948 KB
testcase_14 AC 42 ms
67,948 KB
testcase_15 AC 43 ms
69,996 KB
testcase_16 AC 66 ms
98,024 KB
testcase_17 AC 53 ms
80,448 KB
testcase_18 AC 52 ms
80,476 KB
testcase_19 AC 49 ms
78,504 KB
testcase_20 AC 56 ms
86,968 KB
testcase_21 AC 63 ms
95,900 KB
testcase_22 AC 65 ms
95,900 KB
testcase_23 AC 67 ms
98,072 KB
testcase_24 AC 75 ms
95,904 KB
testcase_25 AC 68 ms
98,072 KB
testcase_26 AC 67 ms
98,072 KB
testcase_27 AC 65 ms
98,072 KB
testcase_28 AC 67 ms
98,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve():
    n = int(input())
    A = list(map(int, input().split()))
    if sum(A) != n or 0 not in A:
        return False

    for b in range(2):
        x = b
        ok = True
        for a in A:
            x = a - (1 - x)
            if x < 0 or 2 <= x:
                ok = False
                break

        if x != b:
            ok = False
        if ok:
            return True
    return False


for _ in range(int(input())):
    if solve():
        print("Yes")
    else:
        print("No")
0