結果

問題 No.2518 Adjacent Larger
ユーザー 👑 H20H20
提出日時 2023-10-27 22:49:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 414 bytes
コンパイル時間 179 ms
コンパイル使用メモリ 81,824 KB
実行使用メモリ 103,744 KB
最終ジャッジ日時 2023-10-27 22:49:49
合計ジャッジ時間 4,495 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,444 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 130 ms
77,776 KB
testcase_07 AC 132 ms
77,776 KB
testcase_08 WA -
testcase_09 AC 133 ms
77,512 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 74 ms
75,992 KB
testcase_16 AC 89 ms
103,724 KB
testcase_17 AC 68 ms
85,048 KB
testcase_18 AC 66 ms
85,072 KB
testcase_19 AC 64 ms
83,100 KB
testcase_20 AC 72 ms
91,564 KB
testcase_21 AC 100 ms
103,744 KB
testcase_22 AC 97 ms
103,744 KB
testcase_23 AC 89 ms
103,480 KB
testcase_24 AC 80 ms
101,484 KB
testcase_25 AC 84 ms
102,088 KB
testcase_26 AC 84 ms
102,084 KB
testcase_27 AC 90 ms
103,744 KB
testcase_28 AC 82 ms
102,016 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
    for i in range(N):
        if A[i]==A[i-1] and A[i]!=1:
            ans = False
        temp+=A[i]-1
        if temp<-1 or 1<temp:
            ans = False
    if ans:
        print('Yes')
    else:
        print('No')
0