結果

問題 No.2518 Adjacent Larger
ユーザー komkompikomkompi
提出日時 2023-10-28 20:48:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 761 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,852 KB
実行使用メモリ 117,124 KB
最終ジャッジ日時 2023-10-28 20:48:44
合計ジャッジ時間 4,551 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,588 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 111 ms
104,588 KB
testcase_22 AC 112 ms
104,628 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 104 ms
117,124 KB
testcase_28 AC 107 ms
117,124 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!

T=int(input())

for _ in range(T):
    N=int(input())
    A=list(map(int,input().split()))
    
    dic={0:0,1:0,2:0}
    
    for a in A:
        dic[a]+=1
    
    n_zero=0
    n_one=dic[0]
    n_two=N-dic[2]
    
    B=[]
    for a in A:
        if a==0:
            B.append(n_zero)
            n_zero+=1
        elif a==1:
            B.append(n_one)
            n_one+=1
        else:
            B.append(n_two)
            n_two+=1
    
    C=[]
    for i in range(N):
        if B[i]>B[i-1] and B[i]>B[(i+1)%N]:
            C.append(2)
        elif B[i]>B[i-1] or B[i]>B[(i+1)%N]:
            C.append(1)
        else:
            C.append(0)
    
    if A==C:
        print("Yes")
    else:
        print("No")
    
0