結果

問題 No.2343 (l+r)/2
ユーザー とろちゃとろちゃ
提出日時 2023-06-09 21:19:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 804 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 11,188 KB
最終ジャッジ日時 2023-08-30 12:48:18
合計ジャッジ時間 3,268 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,864 KB
testcase_01 AC 1,635 ms
7,752 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 41 ms
11,188 KB
testcase_05 AC 25 ms
9,568 KB
testcase_06 AC 24 ms
9,240 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 20 ms
8,560 KB
testcase_11 AC 34 ms
9,624 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 37 ms
9,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def RLE(s):
    result = []
    count = 1
    for i in range(1, len(s)):
        if s[i] == s[i - 1]:
            count += 1
        else:
            result.append((s[i - 1], count))
            count = 1
    result.append((s[-1], count))
    return result


T = int(input())
for _ in range(T):
    N = int(input())
    A = "".join(input().split())
    cnt1 = A.count("1")
    cnt0 = A.count("0")
    rle = RLE(A)
    if cnt1 > cnt0:
        rle1 = len(rle[0::2]) if rle[0][0] == "1" else len(rle[1::2])
        if cnt0 >= rle1:
            print("Yes")
        else:
            print("No")
    elif cnt1 < cnt0:
        rle0 = len(rle[0::2]) if rle[0][0] == "0" else len(rle[1::2])
        if cnt1 >= rle0:
            print("Yes")
        else:
            print("No")
    else:
        print("Yes")
0