結果

問題 No.2021 Not A but B
ユーザー miya145592
提出日時 2023-05-04 08:29:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 54 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 254 ms
コンパイル使用メモリ 82,648 KB
実行使用メモリ 61,312 KB
最終ジャッジ日時 2024-11-22 03:07:23
合計ジャッジ時間 3,117 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = input()
cnt = 0
first = 0
for i in range(N-1):
    if S[i+1]=="A":
        cnt+=1
    elif S[i]=="A":
        if i>=1 and S[i-1]=="B":
            pass
        else:
            cnt+=1
    elif first==0 and S[i]=="B" and S[i+1]=="B":
        first=1
        cnt+=1
print(cnt)
0