結果

問題 No.672 最長AB列
ユーザー syunsukesyunsuke
提出日時 2019-06-02 17:40:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 347 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 11,928 KB
実行使用メモリ 33,860 KB
最終ジャッジ日時 2023-10-17 23:03:57
合計ジャッジ時間 4,749 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,048 KB
testcase_01 AC 29 ms
10,048 KB
testcase_02 AC 28 ms
10,048 KB
testcase_03 AC 29 ms
10,048 KB
testcase_04 WA -
testcase_05 AC 28 ms
10,048 KB
testcase_06 AC 29 ms
10,048 KB
testcase_07 AC 28 ms
10,048 KB
testcase_08 AC 28 ms
10,048 KB
testcase_09 AC 259 ms
30,664 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 249 ms
30,664 KB
testcase_14 WA -
testcase_15 AC 247 ms
30,664 KB
testcase_16 AC 252 ms
30,664 KB
testcase_17 AC 266 ms
33,832 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

A=list(input())

CNT=len(A)
S=[len(A)+1 for i in range(len(A)*2+5)]
E=[0 for i in range(len(A)*2+5)]
for i in range(len(A)):
    if A[i]=="A":
        CNT+=1
    else:
        CNT-=1
    if E[CNT]<i:
        E[CNT]=i
    if S[CNT]>i:
        S[CNT]=i
S[0]=0
ans=0
for i in range(len(S)):
    if ans<(E[i]-S[i]):
        ans=(E[i]-S[i])

print(ans)
0