結果
| 問題 | No.672 最長AB列 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-06-21 01:53:22 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 212 ms / 2,000 ms |
| コード長 | 226 bytes |
| コンパイル時間 | 186 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 21,524 KB |
| 最終ジャッジ日時 | 2024-06-28 12:36:50 |
| 合計ジャッジ時間 | 2,921 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
S=input()
N=len(S)
dp=[-1]*N*3
cum=0
dp[0]=0
ans=0
for i in range(N):
if S[i]=='A':
cum+=1
else :
cum-=1
if dp[cum]!=-1:
ans = max(ans,i+1-dp[cum])
else :
dp[cum]=i+1
print(ans)