結果

問題 No.672 最長AB列
ユーザー 12354865271235486527
提出日時 2019-12-08 21:43:03
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 253 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 10,544 KB
実行使用メモリ 14,232 KB
最終ジャッジ日時 2023-08-30 06:33:07
合計ジャッジ時間 5,447 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,224 KB
testcase_01 AC 15 ms
7,776 KB
testcase_02 AC 15 ms
7,896 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 16 ms
7,832 KB
testcase_05 AC 16 ms
7,848 KB
testcase_06 AC 15 ms
7,784 KB
testcase_07 AC 15 ms
7,816 KB
testcase_08 AC 16 ms
7,972 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

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