結果

問題 No.672 最長AB列
ユーザー fumofumofunifumofumofuni
提出日時 2023-06-21 01:51:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 233 bytes
コンパイル時間 1,616 ms
コンパイル使用メモリ 86,852 KB
実行使用メモリ 107,660 KB
最終ジャッジ日時 2023-09-10 21:31:21
合計ジャッジ時間 3,544 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,436 KB
testcase_01 AC 70 ms
71,564 KB
testcase_02 AC 72 ms
71,280 KB
testcase_03 AC 73 ms
71,284 KB
testcase_04 AC 72 ms
71,440 KB
testcase_05 AC 71 ms
71,296 KB
testcase_06 AC 73 ms
71,424 KB
testcase_07 AC 75 ms
71,432 KB
testcase_08 AC 72 ms
71,332 KB
testcase_09 AC 117 ms
107,660 KB
testcase_10 AC 96 ms
91,020 KB
testcase_11 AC 107 ms
91,032 KB
testcase_12 AC 87 ms
76,556 KB
testcase_13 AC 85 ms
76,480 KB
testcase_14 AC 89 ms
76,680 KB
testcase_15 AC 88 ms
76,720 KB
testcase_16 AC 87 ms
76,576 KB
testcase_17 AC 98 ms
91,096 KB
testcase_18 AC 81 ms
76,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
N=len(S)
mp=dict({})
cum=0
mp[cum]=0
ans=0
for i in range(N):
    if S[i]=='A':
        cum+=1
    else :
        cum-=1
    if cum in mp.keys():
        ans = max(ans,i+1-mp[cum])
    else :
        mp[cum]=i+1

print(ans)
0