結果

問題 No.672 最長AB列
ユーザー irumo8202irumo8202
提出日時 2022-01-28 21:06:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 205 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 109,528 KB
最終ジャッジ日時 2023-08-28 18:39:01
合計ジャッジ時間 3,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,140 KB
testcase_01 AC 69 ms
71,176 KB
testcase_02 AC 70 ms
71,248 KB
testcase_03 AC 68 ms
71,268 KB
testcase_04 WA -
testcase_05 AC 68 ms
71,280 KB
testcase_06 AC 69 ms
71,400 KB
testcase_07 AC 68 ms
71,200 KB
testcase_08 AC 69 ms
71,328 KB
testcase_09 AC 117 ms
109,528 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 85 ms
78,160 KB
testcase_14 WA -
testcase_15 AC 87 ms
78,252 KB
testcase_16 AC 87 ms
78,084 KB
testcase_17 AC 99 ms
92,712 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S = [1 if x == "A" else -1 for x in input()]
left = {}

ans = 0
x = 0
for i, s in enumerate(S, 1):
    x += s
    if x in left:
        ans = max(ans, i - left[x])
    else:
        left[x] = i

print(ans)
0