結果

問題 No.2021 Not A but B
ユーザー norioc
提出日時 2024-04-02 02:53:07
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 246 bytes
コンパイル時間 411 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 75,800 KB
最終ジャッジ日時 2024-09-30 23:03:37
合計ジャッジ時間 2,962 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()

ans = 0
for i in range(1, N):
    a, b = S[i-1], S[i]
    if a == b == 'B': continue
    if a == 'A' and b == 'B':
        if i-2 >= 0 and S[i-2] == 'B': continue
    ans += 1

if 'BB' in S:
    ans += 1

print(ans)
0