結果

問題 No.672 最長AB列
ユーザー _matumo__matumo_
提出日時 2020-12-16 19:17:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 190 ms / 2,000 ms
コード長 135 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 11,840 KB
実行使用メモリ 36,484 KB
最終ジャッジ日時 2023-10-20 09:47:32
合計ジャッジ時間 2,965 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,016 KB
testcase_01 AC 36 ms
10,016 KB
testcase_02 AC 32 ms
10,016 KB
testcase_03 AC 29 ms
10,016 KB
testcase_04 AC 28 ms
10,016 KB
testcase_05 AC 27 ms
10,016 KB
testcase_06 AC 27 ms
10,016 KB
testcase_07 AC 27 ms
10,016 KB
testcase_08 AC 27 ms
10,016 KB
testcase_09 AC 133 ms
36,484 KB
testcase_10 AC 162 ms
23,384 KB
testcase_11 AC 164 ms
23,376 KB
testcase_12 AC 182 ms
10,388 KB
testcase_13 AC 179 ms
10,388 KB
testcase_14 AC 184 ms
10,388 KB
testcase_15 AC 190 ms
10,388 KB
testcase_16 AC 178 ms
10,388 KB
testcase_17 AC 168 ms
23,380 KB
testcase_18 AC 185 ms
10,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
v={0:0}
m=y=0
for i,c in enumerate(S):
    y+=(c>'A')*2-1
    if y in v:  m=max(m,i+1-v[y])
    else:       v[y]=i+1
print(m)
0