結果

問題 No.2021 Not A but B
ユーザー k_o_pasture
提出日時 2022-07-29 22:26:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 263 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,596 KB
実行使用メモリ 74,984 KB
最終ジャッジ日時 2024-07-19 15:33:25
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 7 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
# N = len(S)
ans = N - 1
if N == 2:
	print(1)
	exit()
for i in range(N-2):
	if (S[i] == 'B') & (S[i+2]=='B'):
		ans -= 1
X = 0
for i in range(N-1):
	if (S[i] == 'B') & (S[i+1] == 'B'):
		X += 1
if X > 1:
	ans -= X - 1
print(ans)
0