結果

問題 No.2343 (l+r)/2
ユーザー nikoro256nikoro256
提出日時 2023-06-09 23:40:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 882 bytes
コンパイル時間 235 ms
コンパイル使用メモリ 82,288 KB
実行使用メモリ 86,812 KB
最終ジャッジ日時 2024-06-10 14:44:14
合計ジャッジ時間 2,511 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,476 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 70 ms
86,812 KB
testcase_05 AC 59 ms
72,376 KB
testcase_06 AC 55 ms
70,400 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 55 ms
75,680 KB
testcase_13 AC 49 ms
69,672 KB
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(N,A):
    last=A[0]
    lis=[]
    streak=0
    for i in range(N):
        if last!=A[i]:
            lis.append(streak)
            streak=1
            last=A[i]
        else:
            streak+=1
    lis.append(streak)
    dp=[[False,False] for _ in range(len(lis))]
    dp[0]=[True,True]
    #0使った1使ってない
    for i in range(len(lis)-1):
        if lis[i]==1:
            if dp[i][1]:
                dp[i+1][0]=True
            elif dp[i][0]:
                dp[i+1][1]=True
        else:
            if dp[i][0] or dp[i][1]:
                dp[i+1][0]=True
                if i!=0:
                    dp[i+1][1]=True
    if dp[-1][0]:
        return True
    else:
        return False
    
T=int(input())
for _ in range(T):
    N=int(input())
    A=list(map(int,input().split()))
    if solve(N,A):
        print('Yes')
    else:
        print('No')
0