結果

問題 No.2021 Not A but B
ユーザー lllllll88938494lllllll88938494
提出日時 2022-07-29 22:33:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 94 ms / 2,000 ms
コード長 354 bytes
コンパイル時間 331 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 79,648 KB
最終ジャッジ日時 2023-09-26 21:56:35
合計ジャッジ時間 4,469 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,408 KB
testcase_01 AC 74 ms
71,396 KB
testcase_02 AC 71 ms
71,232 KB
testcase_03 AC 74 ms
71,136 KB
testcase_04 AC 71 ms
71,388 KB
testcase_05 AC 74 ms
71,224 KB
testcase_06 AC 71 ms
71,256 KB
testcase_07 AC 71 ms
71,344 KB
testcase_08 AC 93 ms
79,352 KB
testcase_09 AC 94 ms
79,364 KB
testcase_10 AC 94 ms
79,648 KB
testcase_11 AC 93 ms
79,412 KB
testcase_12 AC 92 ms
79,124 KB
testcase_13 AC 93 ms
79,412 KB
testcase_14 AC 93 ms
79,548 KB
testcase_15 AC 93 ms
79,588 KB
testcase_16 AC 94 ms
79,584 KB
testcase_17 AC 91 ms
79,208 KB
testcase_18 AC 92 ms
79,492 KB
testcase_19 AC 92 ms
79,268 KB
testcase_20 AC 93 ms
79,592 KB
testcase_21 AC 85 ms
75,956 KB
testcase_22 AC 83 ms
76,064 KB
testcase_23 AC 83 ms
75,764 KB
testcase_24 AC 76 ms
75,708 KB
testcase_25 AC 82 ms
76,012 KB
testcase_26 AC 85 ms
79,560 KB
testcase_27 AC 83 ms
79,400 KB
testcase_28 AC 84 ms
79,388 KB
testcase_29 AC 82 ms
79,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

print(ans)

0