結果

問題 No.2021 Not A but B
ユーザー ohanaohana
提出日時 2023-10-02 12:59:31
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 322 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 87,056 KB
実行使用メモリ 91,440 KB
最終ジャッジ日時 2023-10-02 12:59:37
合計ジャッジ時間 5,594 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 74 ms
71,328 KB
testcase_02 AC 68 ms
71,276 KB
testcase_03 AC 71 ms
71,376 KB
testcase_04 WA -
testcase_05 AC 68 ms
71,152 KB
testcase_06 WA -
testcase_07 AC 68 ms
71,376 KB
testcase_08 WA -
testcase_09 AC 120 ms
88,980 KB
testcase_10 WA -
testcase_11 AC 116 ms
88,868 KB
testcase_12 AC 120 ms
89,016 KB
testcase_13 AC 117 ms
89,596 KB
testcase_14 AC 118 ms
88,964 KB
testcase_15 WA -
testcase_16 AC 118 ms
89,096 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 123 ms
89,056 KB
testcase_20 WA -
testcase_21 AC 79 ms
76,472 KB
testcase_22 AC 76 ms
76,528 KB
testcase_23 AC 78 ms
76,564 KB
testcase_24 AC 71 ms
75,572 KB
testcase_25 AC 79 ms
76,608 KB
testcase_26 AC 85 ms
89,516 KB
testcase_27 AC 126 ms
91,440 KB
testcase_28 AC 125 ms
91,372 KB
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import itertools

n = int(input())
s = input()

A = [(k, len(list(g))) for k, g in itertools.groupby(s)]

ans = 0
for i in range(len(A)):
    if A[i][0] == "A":
        if A[i][1] == 1:
            ans += 1
        else:
            ans += A[i][1] + 1

ans += "BB" in s
ans -= A[0][0] == "A" + A[-1][0] == "A"

print(ans)
0