結果

問題 No.672 最長AB列
ユーザー tails1434tails1434
提出日時 2020-01-22 21:40:56
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 681 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 90,084 KB
最終ジャッジ日時 2023-09-23 02:02:56
合計ジャッジ時間 4,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,372 KB
testcase_01 AC 69 ms
71,300 KB
testcase_02 AC 73 ms
71,280 KB
testcase_03 AC 67 ms
71,400 KB
testcase_04 AC 71 ms
71,284 KB
testcase_05 AC 70 ms
71,200 KB
testcase_06 AC 71 ms
71,196 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 75 ms
75,744 KB
testcase_10 AC 76 ms
75,888 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 89 ms
83,008 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def runlegth(S):
    cnt = 1
    d = []
    for i in range(len(S)-1):
        if S[i] == S[i+1]:
            cnt += 1
        else:
            d.append(cnt)
            cnt = 1
    d.append(cnt)
    return d
def main():
    S = input()
    D = runlegth(S)
    first = 0
    second = 0
    ans = 0
    for i in range(len(D)):
        if i % 2 == 0:
            first += D[i]
            ans = max(ans, min(first,second))
            if D[i] >= second:
                second = 0
        else:
            second += D[i]
            ans = max(ans, min(first,second))
            if D[i] >= first:
                first = 0

    print(ans * 2)


if __name__ == "__main__":
    main()
0