結果
問題 | No.672 最長AB列 |
ユーザー |
![]() |
提出日時 | 2024-04-13 15:30:19 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 575 ms / 2,000 ms |
コード長 | 291 bytes |
コンパイル時間 | 261 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 53,164 KB |
最終ジャッジ日時 | 2024-10-03 00:10:07 |
合計ジャッジ時間 | 5,353 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
from collections import defaultdictinf=1<<30mi=defaultdict(lambda:inf)ma=defaultdict(lambda:-inf)S=input()h=0N=len(S)mi[h]=0ma[h]=0for i in range(N):h+=(S[i]=="A")*2-1mi[h]=min(mi[h],i+1)ma[h]=max(ma[h],i+1)ans=0for h in mi:ans=max(ans,ma[h]-mi[h])print(ans)