結果

問題 No.672 最長AB列
ユーザー 👑 H20H20
提出日時 2020-11-05 13:19:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 266 bytes
コンパイル時間 464 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 107,740 KB
最終ジャッジ日時 2023-09-29 16:52:42
合計ジャッジ時間 2,935 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,240 KB
testcase_01 AC 71 ms
71,400 KB
testcase_02 AC 74 ms
71,416 KB
testcase_03 AC 70 ms
71,596 KB
testcase_04 WA -
testcase_05 AC 70 ms
71,168 KB
testcase_06 AC 70 ms
71,356 KB
testcase_07 AC 71 ms
71,164 KB
testcase_08 AC 71 ms
71,132 KB
testcase_09 AC 106 ms
107,740 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 84 ms
76,548 KB
testcase_14 WA -
testcase_15 AC 86 ms
76,824 KB
testcase_16 AC 85 ms
76,688 KB
testcase_17 AC 95 ms
91,252 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
L = len(S)
d = {}
cnt = 0
ans = 0
for i in range(L):
    if S[i]=='A':
        cnt += 1
    else:
        cnt -=1
    if cnt not in d:
        # キーが存在しない場合の処理
        d[cnt] = i
    else:
        ans = max(ans,i-d[cnt])
print(ans)
0