結果

問題 No.672 最長AB列
ユーザー Mr.FukuMr.Fuku
提出日時 2018-07-08 22:06:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 177 ms / 2,000 ms
コード長 292 bytes
コンパイル時間 128 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 35,700 KB
最終ジャッジ日時 2023-09-22 08:13:56
合計ジャッジ時間 2,733 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,912 KB
testcase_01 AC 17 ms
7,812 KB
testcase_02 AC 17 ms
7,800 KB
testcase_03 AC 16 ms
7,796 KB
testcase_04 AC 15 ms
7,888 KB
testcase_05 AC 15 ms
7,908 KB
testcase_06 AC 15 ms
7,836 KB
testcase_07 AC 15 ms
7,832 KB
testcase_08 AC 15 ms
7,968 KB
testcase_09 AC 170 ms
35,700 KB
testcase_10 AC 177 ms
22,664 KB
testcase_11 AC 162 ms
22,660 KB
testcase_12 AC 150 ms
9,624 KB
testcase_13 AC 163 ms
9,692 KB
testcase_14 AC 157 ms
9,728 KB
testcase_15 AC 154 ms
9,704 KB
testcase_16 AC 154 ms
9,724 KB
testcase_17 AC 167 ms
22,624 KB
testcase_18 AC 153 ms
9,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

lst = list(input())

max_length = 0
count_list = {0:-1}
count = 0

for i in range(len(lst)):
    if lst[i]=="A":
        count += 1
    else:
        count -= 1
    count_list.setdefault(count,i)
    max_length = max(max_length,i-count_list[count])

print(max_length if max_length > 1 else 0)
0