結果

問題 No.2021 Not A but B
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-07-29 22:00:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 324 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 77,668 KB
最終ジャッジ日時 2023-09-26 20:54:06
合計ジャッジ時間 4,189 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,276 KB
testcase_01 AC 69 ms
71,560 KB
testcase_02 AC 71 ms
71,036 KB
testcase_03 AC 75 ms
71,272 KB
testcase_04 AC 71 ms
71,412 KB
testcase_05 AC 73 ms
71,204 KB
testcase_06 AC 72 ms
71,524 KB
testcase_07 AC 72 ms
71,276 KB
testcase_08 AC 84 ms
76,936 KB
testcase_09 AC 86 ms
76,904 KB
testcase_10 AC 83 ms
76,828 KB
testcase_11 AC 84 ms
76,872 KB
testcase_12 AC 84 ms
77,140 KB
testcase_13 AC 85 ms
76,936 KB
testcase_14 AC 88 ms
76,940 KB
testcase_15 AC 87 ms
76,996 KB
testcase_16 AC 88 ms
76,944 KB
testcase_17 AC 88 ms
76,984 KB
testcase_18 AC 87 ms
77,084 KB
testcase_19 AC 84 ms
76,920 KB
testcase_20 AC 83 ms
76,720 KB
testcase_21 AC 79 ms
75,888 KB
testcase_22 AC 77 ms
75,640 KB
testcase_23 AC 79 ms
75,876 KB
testcase_24 AC 73 ms
71,116 KB
testcase_25 AC 79 ms
75,908 KB
testcase_26 AC 80 ms
77,668 KB
testcase_27 AC 78 ms
76,432 KB
testcase_28 AC 77 ms
76,552 KB
testcase_29 AC 73 ms
71,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = input()
ans = 0
if "BB" in S:
    ans += 1
S = S.split("B")
lS = len(S)

for i in range(len(S)):

    s = len(S[i])
    if s == 0:
        continue
    if i == 0:
        if i != lS-1:
            ans += s
        else:
            ans += s-1
            
    elif i == lS-1:
        ans += s
    else:
        if s == 1:
            ans += 1
        else:
            ans += s+1
print(ans)
0