結果

問題 No.672 最長AB列
ユーザー 👑 H20H20
提出日時 2020-11-05 13:05:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 325 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 20,464 KB
最終ジャッジ日時 2023-09-29 16:52:36
合計ジャッジ時間 4,001 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,152 KB
testcase_01 AC 15 ms
7,956 KB
testcase_02 AC 14 ms
7,964 KB
testcase_03 AC 14 ms
8,048 KB
testcase_04 AC 14 ms
7,980 KB
testcase_05 AC 14 ms
7,976 KB
testcase_06 AC 14 ms
8,060 KB
testcase_07 AC 14 ms
8,020 KB
testcase_08 AC 14 ms
7,980 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
S=input()

L = len(S)
ACC = [0]*(L+1)
cnt = 0
for i in range(L):
    if S[i]=='A':
        cnt += 1
    else:
        cnt -=1
    ACC[i+1] = cnt
ans = 0
for i in range(L+1):
    for j in reversed(range(i+ans,L+1)):
        if(ACC[i]==ACC[j] and ans < j-i):
            ans = j-i
            break
print(ans)
0