結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-01-21 11:26:19 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 364 bytes |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 26,468 KB |
| 最終ジャッジ日時 | 2024-11-25 05:33:22 |
| 合計ジャッジ時間 | 4,074 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 RE * 1 |
ソースコード
s=input()
cnt=[0]*(len(s)+1)
now=0
for i in range(len(s)):
if s[i]=='A':
now+=1
else:
now-=1
cnt[i+1]=now
if min(cnt)<0:
d=min(cnt)
for i in range(len(s)+1):
cnt[i]+=d
ind=[-1]*(2*10**5)
ans=0
for i in range(len(s)+1):
if ind[cnt[i]]==-1:
ind[cnt[i]]=i
else:
ans=max(ans,i-ind[cnt[i]])
print(ans)