結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,164 KB
testcase_01 AC 68 ms
71,136 KB
testcase_02 AC 67 ms
71,304 KB
testcase_03 AC 67 ms
71,504 KB
testcase_04 WA -
testcase_05 AC 67 ms
71,456 KB
testcase_06 AC 68 ms
71,516 KB
testcase_07 AC 68 ms
71,508 KB
testcase_08 AC 68 ms
71,400 KB
testcase_09 AC 109 ms
107,796 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 83 ms
76,532 KB
testcase_14 WA -
testcase_15 AC 84 ms
76,700 KB
testcase_16 AC 83 ms
76,740 KB
testcase_17 AC 91 ms
91,072 KB
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

S=input()
L = len(S)
d = {}
d[0] = 0
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