結果
| 問題 | No.672 最長AB列 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-11 14:13:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 133 ms / 2,000 ms |
| コード長 | 492 bytes |
| 記録 | |
| コンパイル時間 | 320 ms |
| コンパイル使用メモリ | 82,164 KB |
| 実行使用メモリ | 127,112 KB |
| 最終ジャッジ日時 | 2025-12-11 14:13:47 |
| 合計ジャッジ時間 | 3,436 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
import sys
from collections import defaultdict
from itertools import accumulate
def input(): return sys.stdin.readline().rstrip('\n')
def main():
*s, = accumulate([0] + list(map(lambda x: -1 if x == 'A' else +1, input())))
a = defaultdict(list)
for i, v in enumerate(s):
a[v].append(i)
ans = 0
for k, v in a.items():
ans = max(ans, v[-1] - v[0])
return ans
if __name__ == '__main__':
ret = main()
if ret is not None:
print(ret)