結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
ntuda
|
| 提出日時 | 2024-01-22 21:24:58 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 82 ms / 2,000 ms |
| コード長 | 240 bytes |
| コンパイル時間 | 208 ms |
| コンパイル使用メモリ | 82,280 KB |
| 実行使用メモリ | 94,720 KB |
| 最終ジャッジ日時 | 2024-09-28 06:29:54 |
| 合計ジャッジ時間 | 1,975 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
S = input()
tmp = 0
dic = {}
dic[0] = 0
ans = 0
for i, s in enumerate(S, start=1):
if s == "A":
tmp += 1
else:
tmp -= 1
if tmp in dic:
ans = max(ans,i - dic[tmp])
else:
dic[tmp] = i
print(ans)
ntuda