結果

問題 No.2021 Not A but B
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2022-07-29 21:36:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 315 bytes
コンパイル時間 451 ms
コンパイル使用メモリ 86,896 KB
実行使用メモリ 76,832 KB
最終ジャッジ日時 2023-09-26 19:48:43
合計ジャッジ時間 4,310 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,256 KB
testcase_01 AC 74 ms
71,032 KB
testcase_02 AC 72 ms
71,220 KB
testcase_03 AC 74 ms
71,172 KB
testcase_04 AC 74 ms
71,112 KB
testcase_05 AC 74 ms
71,096 KB
testcase_06 AC 74 ms
71,152 KB
testcase_07 AC 72 ms
70,984 KB
testcase_08 AC 90 ms
76,628 KB
testcase_09 AC 90 ms
76,416 KB
testcase_10 AC 90 ms
76,684 KB
testcase_11 AC 90 ms
76,660 KB
testcase_12 AC 88 ms
76,388 KB
testcase_13 AC 90 ms
76,432 KB
testcase_14 AC 89 ms
76,424 KB
testcase_15 AC 90 ms
76,800 KB
testcase_16 AC 88 ms
76,304 KB
testcase_17 AC 89 ms
76,832 KB
testcase_18 AC 90 ms
76,616 KB
testcase_19 AC 91 ms
76,296 KB
testcase_20 AC 90 ms
76,316 KB
testcase_21 AC 79 ms
75,636 KB
testcase_22 AC 81 ms
75,640 KB
testcase_23 AC 80 ms
75,624 KB
testcase_24 AC 79 ms
75,524 KB
testcase_25 AC 81 ms
75,636 KB
testcase_26 AC 85 ms
76,192 KB
testcase_27 AC 84 ms
76,232 KB
testcase_28 AC 85 ms
75,952 KB
testcase_29 AC 92 ms
75,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin

N = int(stdin.readline())

bb = 0
other = 0

S = stdin.readline()[:-1]

for i in range(N-1):

    if S[i]+S[i+1] == "BB":
        bb += 1
    else:
        other += 1

ans = other + min(bb,1)

for i in range(N-2):
    if S[i]+S[i+1]+S[i+2] == "BAB":
        ans -= 1

print (ans)
0