結果

問題 No.2518 Adjacent Larger
コンテスト
ユーザー yu_w(ゆ)
提出日時 2023-10-27 22:02:16
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 143 ms / 2,000 ms
コード長 378 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 142 ms
コンパイル使用メモリ 85,504 KB
実行使用メモリ 102,016 KB
最終ジャッジ日時 2026-04-12 18:43:04
合計ジャッジ時間 3,757 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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