結果

問題 No.2343 (l+r)/2
ユーザー nikoro256nikoro256
提出日時 2023-06-09 23:16:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 547 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 87,260 KB
実行使用メモリ 94,960 KB
最終ジャッジ日時 2023-08-30 14:27:37
合計ジャッジ時間 3,385 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,272 KB
testcase_01 AC 613 ms
78,984 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 93 ms
89,556 KB
testcase_05 AC 83 ms
79,092 KB
testcase_06 AC 80 ms
77,944 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 87 ms
86,800 KB
testcase_13 AC 81 ms
81,716 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[1:-1].count(1)==len(lis)-2:
        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