結果

問題 No.2343 (l+r)/2
ユーザー nikoro256nikoro256
提出日時 2023-06-09 22:48:18
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 539 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 87,036 KB
実行使用メモリ 94,936 KB
最終ジャッジ日時 2023-08-30 13:57:36
合計ジャッジ時間 3,496 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,460 KB
testcase_01 AC 646 ms
78,664 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 94 ms
89,076 KB
testcase_05 AC 82 ms
78,996 KB
testcase_06 AC 82 ms
77,904 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 88 ms
86,940 KB
testcase_13 AC 84 ms
81,696 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)
    if A.count(1)==0 or A.count(0)==0:
        return False
    if len(lis)%2==1 and lis.count(1)==len(lis):
        return False
    return True

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