結果

問題 No.2518 Adjacent Larger
ユーザー yu_w(ゆ)yu_w(ゆ)
提出日時 2023-10-27 22:02:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 81,768 KB
実行使用メモリ 101,396 KB
最終ジャッジ日時 2023-10-27 22:02:20
合計ジャッジ時間 4,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,492 KB
testcase_01 AC 162 ms
76,848 KB
testcase_02 AC 168 ms
76,872 KB
testcase_03 AC 186 ms
77,476 KB
testcase_04 AC 168 ms
77,636 KB
testcase_05 AC 169 ms
77,636 KB
testcase_06 AC 102 ms
76,932 KB
testcase_07 AC 101 ms
76,832 KB
testcase_08 AC 101 ms
76,952 KB
testcase_09 AC 103 ms
77,016 KB
testcase_10 AC 104 ms
76,864 KB
testcase_11 AC 67 ms
75,580 KB
testcase_12 AC 67 ms
75,568 KB
testcase_13 AC 66 ms
75,544 KB
testcase_14 AC 59 ms
73,264 KB
testcase_15 AC 61 ms
74,072 KB
testcase_16 AC 98 ms
100,504 KB
testcase_17 AC 63 ms
84,992 KB
testcase_18 AC 60 ms
82,948 KB
testcase_19 AC 58 ms
80,980 KB
testcase_20 AC 65 ms
89,460 KB
testcase_21 AC 81 ms
101,396 KB
testcase_22 AC 80 ms
100,560 KB
testcase_23 AC 79 ms
100,552 KB
testcase_24 AC 68 ms
98,228 KB
testcase_25 AC 71 ms
98,348 KB
testcase_26 AC 73 ms
98,364 KB
testcase_27 AC 81 ms
100,592 KB
testcase_28 AC 75 ms
98,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for _ in range(T):
    N=int(input())
    A=list(map(int,input().split()))
    now=0
    mxnow=now
    mnnow=now
    for i in range(N):
        if A[i]==2:
            now+=1
        elif A[i]==0:
            now-=1
        mxnow=max(now,mxnow)
        mnnow=min(now,mnnow)
    
    if now==0 and mxnow-mnnow==1:
        print("Yes")
    else:
        print("No")
0