結果

問題 No.2021 Not A but B
ユーザー ああいいああいい
提出日時 2022-07-31 13:04:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 436 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 76,608 KB
最終ジャッジ日時 2023-09-28 04:04:02
合計ジャッジ時間 3,489 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
71,304 KB
testcase_01 AC 65 ms
71,368 KB
testcase_02 AC 64 ms
71,388 KB
testcase_03 AC 63 ms
71,300 KB
testcase_04 AC 64 ms
71,300 KB
testcase_05 AC 63 ms
71,496 KB
testcase_06 AC 61 ms
71,304 KB
testcase_07 AC 64 ms
71,408 KB
testcase_08 AC 74 ms
76,392 KB
testcase_09 AC 74 ms
76,132 KB
testcase_10 AC 72 ms
76,608 KB
testcase_11 AC 75 ms
76,388 KB
testcase_12 AC 76 ms
76,384 KB
testcase_13 AC 75 ms
76,316 KB
testcase_14 AC 76 ms
76,264 KB
testcase_15 AC 74 ms
76,468 KB
testcase_16 AC 70 ms
76,364 KB
testcase_17 AC 72 ms
76,376 KB
testcase_18 AC 72 ms
76,448 KB
testcase_19 AC 76 ms
76,248 KB
testcase_20 AC 73 ms
76,360 KB
testcase_21 AC 69 ms
76,160 KB
testcase_22 AC 70 ms
76,020 KB
testcase_23 AC 69 ms
75,932 KB
testcase_24 AC 67 ms
75,832 KB
testcase_25 AC 70 ms
75,736 KB
testcase_26 AC 68 ms
76,200 KB
testcase_27 AC 72 ms
76,180 KB
testcase_28 AC 69 ms
75,968 KB
testcase_29 AC 68 ms
76,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

ans = 0
flag = False
for i in range(len(S) - 1):
    if S[i] == "A":
        if S[i + 1] == "A":
            ans += 1
        else:
            if i > 0 and S[i-1] == "A":
                ans += 1
            elif i == 0:
                ans += 1
    else:
        if S[i+1] == "A":
            ans += 1
        else:
            if not flag:
                ans += 1
                flag = True
print(ans)
0