結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
73,168 KB
testcase_01 AC 111 ms
73,100 KB
testcase_02 AC 113 ms
73,288 KB
testcase_03 AC 111 ms
73,404 KB
testcase_04 AC 113 ms
73,312 KB
testcase_05 AC 111 ms
73,136 KB
testcase_06 AC 110 ms
73,096 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 154 ms
109,716 KB
testcase_10 AC 139 ms
93,496 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 138 ms
93,068 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 + 1 - D[val])
		D[val] = i + 1

	print(ans)


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