結果

問題 No.672 最長AB列
ユーザー 1235486527
提出日時 2019-12-08 21:43:03
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 253 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 24,848 KB
最終ジャッジ日時 2024-12-31 18:53:21
合計ジャッジ時間 29,143 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 TLE * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
a = [None] * (len(S)+1)
a[0] = 0
c = 0
max_len = 0
for i, s in enumerate(S, 1):
    if s == "A":
        c += 1
    else:
        c -= 1
    if c in a:
        max_len = max(max_len, i - a.index(c))
    else:
        a[i] = c

print(max_len)
0