結果

問題 No.672 最長AB列
ユーザー irumo8202
提出日時 2022-01-28 21:06:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 205 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 102,528 KB
最終ジャッジ日時 2024-12-30 03:35:01
合計ジャッジ時間 2,521 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

S = [1 if x == "A" else -1 for x in input()]
left = {}

ans = 0
x = 0
for i, s in enumerate(S, 1):
    x += s
    if x in left:
        ans = max(ans, i - left[x])
    else:
        left[x] = i

print(ans)
0