結果

問題 No.2343 (l+r)/2
ユーザー nikoro256nikoro256
提出日時 2023-06-09 23:59:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 897 bytes
コンパイル時間 346 ms
コンパイル使用メモリ 82,372 KB
実行使用メモリ 85,984 KB
最終ジャッジ日時 2024-06-10 15:03:14
合計ジャッジ時間 2,765 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,380 KB
testcase_01 AC 563 ms
77,420 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 63 ms
85,984 KB
testcase_05 AC 51 ms
71,112 KB
testcase_06 AC 49 ms
69,908 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 42 ms
63,904 KB
testcase_11 AC 56 ms
79,300 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 60 ms
85,640 KB
権限があれば一括ダウンロードができます

ソースコード

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]=[False,True]
    #0使った1使ってない
    for i in range(len(lis)-1):
        if lis[i]==1:
            if dp[i][1]:
                dp[i+1][0]=True
            if dp[i][0]:
                dp[i+1][1]=True
        else:
            if dp[i][0]:
                dp[i+1][0]=True
                dp[i+1][1]=True
            if dp[i][1]:
                dp[i+1][0]=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