結果

問題 No.2518 Adjacent Larger
ユーザー yu_w(ゆ)
提出日時 2023-10-27 21:56:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 505 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,472 KB
実行使用メモリ 98,784 KB
最終ジャッジ日時 2024-09-25 14:02:35
合計ジャッジ時間 4,338 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 14 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

T=int(input())
for _ in range(T):
    N=int(input())
    A=list(map(int,input().split()))
    now=0
    judge=True
    allone=True
    for i in range(N):
        if A[i]==2:
            now+=1
            allone=False
        elif A[i]==0:
            now-=1
            allone=False
        if now>=2 or now<=-2:
            judge=False
            break
    
    if now!=0:
        judge=False
    if allone:
        judge=False
        
    if judge:
        print("Yes")
    else:
        print("No")
0