結果

問題 No.672 最長AB列
ユーザー matsukin1111matsukin1111
提出日時 2018-12-14 10:38:51
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 256 ms / 2,000 ms
コード長 299 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 38,184 KB
最終ジャッジ日時 2023-10-25 09:56:11
合計ジャッジ時間 3,426 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
9,952 KB
testcase_01 AC 29 ms
9,952 KB
testcase_02 AC 29 ms
9,952 KB
testcase_03 AC 28 ms
9,952 KB
testcase_04 AC 25 ms
9,952 KB
testcase_05 AC 27 ms
9,952 KB
testcase_06 AC 27 ms
9,952 KB
testcase_07 AC 27 ms
9,952 KB
testcase_08 AC 27 ms
9,952 KB
testcase_09 AC 256 ms
38,184 KB
testcase_10 AC 235 ms
26,348 KB
testcase_11 AC 245 ms
26,496 KB
testcase_12 AC 218 ms
13,360 KB
testcase_13 AC 227 ms
18,112 KB
testcase_14 AC 212 ms
13,888 KB
testcase_15 AC 217 ms
15,208 KB
testcase_16 AC 210 ms
16,000 KB
testcase_17 AC 237 ms
27,800 KB
testcase_18 AC 202 ms
11,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
mx = 0
ss = [0 for j in range(len(s)+1)]

sss = {0:0}

for a , b in enumerate(s):
    if b == "A":
        ss[a+1] = ss[a] + 1
    else:
        ss[a+1] = ss[a] - 1
    if not ss[a+1] in sss:
        sss[ss[a+1]]  = a + 1

for a , b in enumerate(ss):
    mx = max(mx,a-sss[b])
print(mx)
0