結果

問題 No.672 最長AB列
ユーザー 12354865271235486527
提出日時 2019-12-08 21:54:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 150 ms / 2,000 ms
コード長 223 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 10,548 KB
実行使用メモリ 34,396 KB
最終ジャッジ日時 2023-08-30 07:05:18
合計ジャッジ時間 3,387 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,844 KB
testcase_01 AC 15 ms
7,860 KB
testcase_02 AC 15 ms
7,896 KB
testcase_03 AC 15 ms
7,824 KB
testcase_04 AC 15 ms
7,892 KB
testcase_05 AC 15 ms
7,792 KB
testcase_06 AC 15 ms
7,876 KB
testcase_07 AC 14 ms
7,816 KB
testcase_08 AC 15 ms
7,852 KB
testcase_09 AC 106 ms
34,396 KB
testcase_10 AC 129 ms
21,516 KB
testcase_11 AC 124 ms
21,324 KB
testcase_12 AC 146 ms
8,452 KB
testcase_13 AC 150 ms
8,328 KB
testcase_14 AC 147 ms
8,348 KB
testcase_15 AC 145 ms
8,284 KB
testcase_16 AC 148 ms
8,356 KB
testcase_17 AC 128 ms
21,396 KB
testcase_18 AC 148 ms
8,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
a = {0: -1}
c = 0
max_len = 0
for i, s in enumerate(S):
    if s == "A":
        c += 1
    else:
        c -= 1
    if c in a:
        max_len = max(max_len, i - a[c])
    else:
        a[c] = i

print(max_len)
0