結果

問題 No.2021 Not A but B
ユーザー k_o_pasturek_o_pasture
提出日時 2022-07-29 22:48:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 86,272 KB
最終ジャッジ日時 2024-07-19 16:01:56
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 18 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
if N == 2:
	print(1)
	exit()

T = []
for i in range(N-1):
	if (S[i] == 'B') & (S[i+1] == 'B'):
		pass
	else:
		T.append(S[i])
if (S[-1] == 'B') & (S[-2] == 'B'):
	T.append('B')
elif S[-1] == 'A':
	T.append('A')
# print(''.join(T))
M = len(T)
X = 0
for i in range(M-2):
	if (T[i] == 'B') & (T[i+2]=='B'):
		X += 1
ans = M - X
print(ans)
0