結果

問題 No.2021 Not A but B
ユーザー jakujaku12jakujaku12
提出日時 2022-07-29 21:44:43
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 201 bytes
コンパイル時間 1,466 ms
コンパイル使用メモリ 86,964 KB
実行使用メモリ 76,624 KB
最終ジャッジ日時 2023-09-26 20:16:56
合計ジャッジ時間 5,138 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,100 KB
testcase_01 AC 73 ms
71,252 KB
testcase_02 AC 73 ms
71,164 KB
testcase_03 AC 73 ms
71,300 KB
testcase_04 AC 71 ms
71,356 KB
testcase_05 AC 72 ms
71,248 KB
testcase_06 AC 72 ms
71,296 KB
testcase_07 AC 73 ms
71,396 KB
testcase_08 AC 93 ms
76,340 KB
testcase_09 AC 89 ms
76,472 KB
testcase_10 AC 87 ms
76,360 KB
testcase_11 AC 87 ms
76,624 KB
testcase_12 AC 87 ms
76,344 KB
testcase_13 AC 86 ms
76,488 KB
testcase_14 AC 88 ms
76,472 KB
testcase_15 AC 89 ms
76,284 KB
testcase_16 AC 89 ms
76,440 KB
testcase_17 AC 86 ms
76,432 KB
testcase_18 AC 89 ms
76,604 KB
testcase_19 AC 87 ms
76,324 KB
testcase_20 AC 87 ms
76,364 KB
testcase_21 AC 82 ms
76,028 KB
testcase_22 AC 84 ms
76,048 KB
testcase_23 AC 85 ms
76,028 KB
testcase_24 AC 78 ms
75,808 KB
testcase_25 AC 82 ms
76,144 KB
testcase_26 AC 81 ms
76,416 KB
testcase_27 AC 82 ms
76,480 KB
testcase_28 AC 84 ms
76,244 KB
testcase_29 AC 80 ms
76,284 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
S=input()
ans=0
cnt=-1
for i in range(N-1):
    if i+2<N and S[i]=="B" and S[i+1]=="A" and S[i+2]=="B":
        ans+=1
    if S[i]==S[i+1]=="B":
        cnt+=1
print(N-1-max(0,cnt)-ans)
0