結果

問題 No.672 最長AB列
ユーザー tails1434tails1434
提出日時 2020-01-22 21:52:48
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 679 bytes
コンパイル時間 2,622 ms
コンパイル使用メモリ 86,520 KB
実行使用メモリ 89,732 KB
最終ジャッジ日時 2023-09-23 02:24:18
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,160 KB
testcase_01 AC 71 ms
71,056 KB
testcase_02 AC 71 ms
71,348 KB
testcase_03 AC 71 ms
70,928 KB
testcase_04 AC 72 ms
71,256 KB
testcase_05 AC 71 ms
71,152 KB
testcase_06 AC 72 ms
71,132 KB
testcase_07 AC 73 ms
71,168 KB
testcase_08 AC 70 ms
71,112 KB
testcase_09 AC 78 ms
75,692 KB
testcase_10 AC 79 ms
75,508 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 90 ms
82,592 KB
testcase_18 AC 94 ms
89,732 KB
権限があれば一括ダウンロードができます

ソースコード

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