結果
問題 |
No.672 最長AB列
|
ユーザー |
|
提出日時 | 2019-01-01 21:28:35 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 186 ms / 2,000 ms |
コード長 | 254 bytes |
コンパイル時間 | 89 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 38,396 KB |
最終ジャッジ日時 | 2024-11-08 02:50:50 |
合計ジャッジ時間 | 2,896 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
# -*- coding: utf-8 -*- s = list(input()) n = len(s) d = {0:-1} cnt = 0 res = 0 for i in range(n): if s[i]=="A": cnt += 1 else: cnt -= 1 if cnt in d: res = max(res, i-d[cnt]) else: d[cnt] = i print(res)