結果

問題 No.672 最長AB列
コンテスト
ユーザー 1235486527
提出日時 2019-12-08 21:43:03
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
TLE  
実行時間 -
コード長 253 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 56 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 12,928 KB
最終ジャッジ日時 2026-10-10 00:41:32
合計ジャッジ時間 6,512 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 TLE * 1 -- * 9
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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