結果

問題 No.672 最長AB列
ユーザー NoneNone
提出日時 2021-03-05 20:31:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 218 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 95,040 KB
最終ジャッジ日時 2024-04-16 08:03:57
合計ジャッジ時間 2,435 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,952 KB
testcase_01 AC 38 ms
52,292 KB
testcase_02 AC 38 ms
52,580 KB
testcase_03 AC 38 ms
52,192 KB
testcase_04 WA -
testcase_05 AC 39 ms
53,424 KB
testcase_06 AC 39 ms
52,356 KB
testcase_07 AC 39 ms
52,956 KB
testcase_08 AC 38 ms
53,576 KB
testcase_09 AC 77 ms
95,040 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 64 ms
75,752 KB
testcase_14 WA -
testcase_15 AC 65 ms
75,948 KB
testcase_16 AC 64 ms
75,904 KB
testcase_17 AC 76 ms
90,104 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input().rstrip()
N=len(S)

res=0
c=dict()
A,B=0,0
for i in range(N):
    s=S[i]
    if s=="A":
        A+=1
    else:
        B+=1
    if A-B in c:
        res=max(i-c[A-B],res)
    else:
        c[A-B]=i

print(res)
0