結果
問題 |
No.672 最長AB列
|
ユーザー |
![]() |
提出日時 | 2018-04-13 23:29:58 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 492 bytes |
コンパイル時間 | 216 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 21,504 KB |
最終ジャッジ日時 | 2024-06-27 19:44:54 |
合計ジャッジ時間 | 2,864 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 WA * 4 |
ソースコード
S = input() mem = [0] a = b = 0 for c in S: if c == 'A': mem.append(mem[-1] + 1) a += 1 else: mem.append(mem[-1] - 1) b += 1 def judge(n): for a,b in zip(mem, mem[n*2:]): if a == b: return True for a,b in zip(mem[1:], mem[n*2+1:]): if a == b: return True return False ok = 0 ng = min(a,b)+1 while ng-ok > 1: m = (ng+ok) // 2 if judge(m): ok = m else: ng = m print(ok*2)