結果

問題 No.672 最長AB列
ユーザー _matumo__matumo_
提出日時 2020-12-16 22:39:59
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 179 ms / 2,000 ms
コード長 132 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 11,720 KB
実行使用メモリ 36,432 KB
最終ジャッジ日時 2023-10-20 09:55:44
合計ジャッジ時間 3,123 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
9,964 KB
testcase_01 AC 28 ms
9,964 KB
testcase_02 AC 29 ms
9,964 KB
testcase_03 AC 28 ms
9,964 KB
testcase_04 AC 27 ms
9,964 KB
testcase_05 AC 28 ms
9,964 KB
testcase_06 AC 28 ms
9,964 KB
testcase_07 AC 28 ms
9,964 KB
testcase_08 AC 28 ms
9,964 KB
testcase_09 AC 127 ms
36,432 KB
testcase_10 AC 155 ms
23,332 KB
testcase_11 AC 153 ms
23,324 KB
testcase_12 AC 174 ms
10,336 KB
testcase_13 AC 174 ms
10,336 KB
testcase_14 AC 176 ms
10,336 KB
testcase_15 AC 179 ms
10,336 KB
testcase_16 AC 176 ms
10,336 KB
testcase_17 AC 156 ms
23,328 KB
testcase_18 AC 171 ms
10,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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