結果

問題 No.2021 Not A but B
ユーザー lllllll88938494
提出日時 2022-07-29 22:11:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 329 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,564 KB
実行使用メモリ 72,916 KB
最終ジャッジ日時 2024-07-19 15:01:01
合計ジャッジ時間 2,644 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 8 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=list(input())
ans=0
f = 0

for i in range(n):
    if i < n-1:
        if s[i] == 'B' and s[i+1] == 'B':
            if f==0:
                ans+=1
            f=1
            continue
        ans+=1

    if i - 2 >= 0:
        if s[i] ==  'B' and s[i-2] == 'B' and s[i-1] == 'A':
            ans-=1


print(ans)
0