結果

問題 No.672 最長AB列
ユーザー 双六双六
提出日時 2020-07-25 15:22:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 515 bytes
コンパイル時間 292 ms
コンパイル使用メモリ 86,816 KB
実行使用メモリ 109,960 KB
最終ジャッジ日時 2023-09-09 13:40:14
合計ジャッジ時間 4,668 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 110 ms
73,344 KB
testcase_01 AC 110 ms
73,532 KB
testcase_02 AC 115 ms
73,192 KB
testcase_03 AC 111 ms
73,360 KB
testcase_04 WA -
testcase_05 AC 110 ms
73,352 KB
testcase_06 AC 109 ms
73,836 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 165 ms
109,960 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 139 ms
93,028 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# import sys; input = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**7)
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

import random

#処理内容
def main():
	L = input()
	N = len(L)
	D = defaultdict(lambda:-1)
	D[0] = 0
	ans = 0
	val = 0
	for i in range(N):
		if L[i] == "A":
			val += 1
		else:
			val -= 1
		if D[val] != -1:
			ans = max(ans, i - D[val])
		D[val] = i

	print(ans)


	
if __name__ == '__main__':
	main()
0