結果
問題 | No.672 最長AB列 |
ユーザー |
![]() |
提出日時 | 2018-07-08 22:06:12 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 203 ms / 2,000 ms |
コード長 | 292 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 38,520 KB |
最終ジャッジ日時 | 2024-07-08 00:34:52 |
合計ジャッジ時間 | 3,128 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
lst = list(input()) max_length = 0 count_list = {0:-1} count = 0 for i in range(len(lst)): if lst[i]=="A": count += 1 else: count -= 1 count_list.setdefault(count,i) max_length = max(max_length,i-count_list[count]) print(max_length if max_length > 1 else 0)