結果

問題 No.2518 Adjacent Larger
ユーザー 👑 H20H20
提出日時 2023-10-27 22:54:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 236 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 304 ms
コンパイル使用メモリ 81,864 KB
実行使用メモリ 103,696 KB
最終ジャッジ日時 2023-10-27 22:54:16
合計ジャッジ時間 5,046 ms
ジャッジサーバーID
(参考情報)
judge10 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
55,408 KB
testcase_01 AC 236 ms
78,104 KB
testcase_02 AC 224 ms
77,236 KB
testcase_03 AC 220 ms
77,264 KB
testcase_04 AC 232 ms
77,356 KB
testcase_05 AC 226 ms
77,532 KB
testcase_06 AC 159 ms
77,204 KB
testcase_07 AC 156 ms
77,204 KB
testcase_08 AC 160 ms
77,732 KB
testcase_09 AC 161 ms
77,732 KB
testcase_10 AC 157 ms
77,204 KB
testcase_11 AC 90 ms
75,956 KB
testcase_12 AC 91 ms
75,968 KB
testcase_13 AC 96 ms
76,028 KB
testcase_14 AC 86 ms
76,024 KB
testcase_15 AC 90 ms
75,992 KB
testcase_16 AC 98 ms
103,676 KB
testcase_17 AC 74 ms
87,096 KB
testcase_18 AC 73 ms
87,112 KB
testcase_19 AC 70 ms
85,140 KB
testcase_20 AC 79 ms
92,428 KB
testcase_21 AC 104 ms
103,696 KB
testcase_22 AC 99 ms
103,696 KB
testcase_23 AC 96 ms
103,696 KB
testcase_24 AC 84 ms
101,824 KB
testcase_25 AC 90 ms
103,696 KB
testcase_26 AC 93 ms
103,696 KB
testcase_27 AC 98 ms
103,696 KB
testcase_28 AC 92 ms
103,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))
    C = collections.Counter(A)
    ans = C[0]==C[2] and C[1]<N
    temp = 0
    mitemp = 0
    matemp = 0
    for i in range(N):
        if A[i]==A[i-1] and A[i]!=1:
            ans = False
        temp+=A[i]-1
        mitemp = min(temp,mitemp)
        matemp = max(temp,matemp)
        if matemp-mitemp>1:
            ans = False
    if ans:
        print('Yes')
    else:
        print('No')
0