結果

問題 No.672 最長AB列
ユーザー 👑 H20H20
提出日時 2020-11-05 13:03:55
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 325 bytes
コンパイル時間 262 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 83,240 KB
最終ジャッジ日時 2023-09-29 16:52:25
合計ジャッジ時間 4,638 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,288 KB
testcase_01 AC 67 ms
71,484 KB
testcase_02 AC 70 ms
71,276 KB
testcase_03 AC 69 ms
71,284 KB
testcase_04 AC 71 ms
71,388 KB
testcase_05 AC 68 ms
71,404 KB
testcase_06 AC 70 ms
71,340 KB
testcase_07 AC 67 ms
71,160 KB
testcase_08 AC 68 ms
71,276 KB
testcase_09 TLE -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools
S=input()

L = len(S)
ACC = [0]*(L+1)
cnt = 0
for i in range(L):
    if S[i]=='A':
        cnt += 1
    else:
        cnt -=1
    ACC[i+1] = cnt
ans = 0
for i in range(L+1):
    for j in reversed(range(i+ans,L+1)):
        if(ACC[i]==ACC[j] and ans < j-i):
            ans = j-i
            break
print(ans)
0