結果

問題 No.672 最長AB列
ユーザー konsin_tokagekonsin_tokage
提出日時 2018-04-14 21:45:23
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 176 ms / 2,000 ms
コード長 200 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 10,564 KB
実行使用メモリ 34,364 KB
最終ジャッジ日時 2023-09-10 04:26:25
合計ジャッジ時間 2,833 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,804 KB
testcase_01 AC 15 ms
7,868 KB
testcase_02 AC 16 ms
7,860 KB
testcase_03 AC 18 ms
7,796 KB
testcase_04 AC 15 ms
7,952 KB
testcase_05 AC 16 ms
7,880 KB
testcase_06 AC 15 ms
7,796 KB
testcase_07 AC 16 ms
7,836 KB
testcase_08 AC 16 ms
7,952 KB
testcase_09 AC 121 ms
34,364 KB
testcase_10 AC 144 ms
21,280 KB
testcase_11 AC 141 ms
21,320 KB
testcase_12 AC 166 ms
8,320 KB
testcase_13 AC 176 ms
8,308 KB
testcase_14 AC 163 ms
8,248 KB
testcase_15 AC 165 ms
8,296 KB
testcase_16 AC 166 ms
8,336 KB
testcase_17 AC 148 ms
21,444 KB
testcase_18 AC 161 ms
8,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

s = input()
x = {}
d = r = 0
for i, c in enumerate(s):
    if d not in x:
        x[d] = i
    if c == 'A':
        d += 1
    else:
        d -= 1
    if d in x:
        r = max(r, i-x[d]+1)
print(r)
0