結果

問題 No.672 最長AB列
ユーザー pluto77pluto77
提出日時 2018-04-14 11:43:52
言語 Python2
(2.7.18)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 218 bytes
コンパイル時間 1,362 ms
コンパイル使用メモリ 7,124 KB
実行使用メモリ 33,024 KB
最終ジャッジ日時 2023-09-10 04:24:04
合計ジャッジ時間 3,213 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
6,212 KB
testcase_01 AC 13 ms
6,276 KB
testcase_02 AC 13 ms
6,200 KB
testcase_03 AC 13 ms
6,344 KB
testcase_04 AC 13 ms
6,452 KB
testcase_05 AC 13 ms
6,420 KB
testcase_06 AC 13 ms
6,284 KB
testcase_07 AC 12 ms
6,292 KB
testcase_08 AC 13 ms
6,240 KB
testcase_09 AC 96 ms
33,024 KB
testcase_10 AC 103 ms
19,536 KB
testcase_11 AC 103 ms
19,708 KB
testcase_12 AC 106 ms
6,496 KB
testcase_13 AC 111 ms
6,540 KB
testcase_14 AC 106 ms
6,620 KB
testcase_15 AC 108 ms
6,460 KB
testcase_16 AC 109 ms
6,604 KB
testcase_17 AC 111 ms
19,616 KB
testcase_18 AC 104 ms
6,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki672
from collections import defaultdict

s=raw_input()
d=defaultdict(int)
p=0
d[0]=-1
res=0
for i in xrange(len(s)):
 if s[i]=='A':
  p+=1
 else:
  p-=1
 if p in d:
  res=max(res,i-d[p])
 else:
  d[p]=i
print res
0