結果

問題 No.2343 (l+r)/2
ユーザー miya145592miya145592
提出日時 2023-06-10 00:43:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 594 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 95,384 KB
最終ジャッジ日時 2023-08-30 15:40:09
合計ジャッジ時間 3,405 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,344 KB
testcase_01 AC 594 ms
78,416 KB
testcase_02 AC 115 ms
77,520 KB
testcase_03 AC 220 ms
79,044 KB
testcase_04 AC 84 ms
86,872 KB
testcase_05 AC 77 ms
78,452 KB
testcase_06 AC 75 ms
77,496 KB
testcase_07 AC 88 ms
77,780 KB
testcase_08 AC 89 ms
77,448 KB
testcase_09 AC 86 ms
78,260 KB
testcase_10 AC 79 ms
78,156 KB
testcase_11 AC 91 ms
90,836 KB
testcase_12 AC 88 ms
87,288 KB
testcase_13 AC 84 ms
82,208 KB
testcase_14 AC 99 ms
95,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    N = int(input())
    A = list(map(int, input().split()))

    if N==1:
        print("No")
        continue

    if A[0]!=A[-1]:
        print("Yes")
        continue

    flag = 0
    for i in range(N-1):
        if A[i]==A[i+1]==(1-A[0]):
            flag = 1
            break
    if flag:
        print("Yes")
        continue

    cnt = 0
    for i in range(N):
        if A[i]==(1-A[0]):
            cnt+=1
    if cnt>=4:
        print("Yes")
    else:
        print("No")
0