結果
問題 | No.672 最長AB列 |
ユーザー |
|
提出日時 | 2023-06-21 01:51:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 75 ms / 2,000 ms |
コード長 | 233 bytes |
コンパイル時間 | 150 ms |
コンパイル使用メモリ | 82,188 KB |
実行使用メモリ | 94,848 KB |
最終ジャッジ日時 | 2024-06-28 12:34:47 |
合計ジャッジ時間 | 1,925 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
S=input() N=len(S) mp=dict({}) cum=0 mp[cum]=0 ans=0 for i in range(N): if S[i]=='A': cum+=1 else : cum-=1 if cum in mp.keys(): ans = max(ans,i+1-mp[cum]) else : mp[cum]=i+1 print(ans)