結果

問題 No.2021 Not A but B
ユーザー k_o_pasturek_o_pasture
提出日時 2022-07-29 22:48:17
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 370 bytes
コンパイル時間 820 ms
コンパイル使用メモリ 87,144 KB
実行使用メモリ 93,280 KB
最終ジャッジ日時 2023-09-26 22:15:13
合計ジャッジ時間 4,856 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 75 ms
71,400 KB
testcase_02 WA -
testcase_03 AC 75 ms
71,180 KB
testcase_04 AC 75 ms
71,436 KB
testcase_05 AC 76 ms
71,520 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 106 ms
90,276 KB
testcase_09 WA -
testcase_10 AC 109 ms
90,400 KB
testcase_11 AC 107 ms
88,668 KB
testcase_12 AC 108 ms
88,808 KB
testcase_13 WA -
testcase_14 AC 111 ms
90,076 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 106 ms
88,644 KB
testcase_18 AC 107 ms
90,188 KB
testcase_19 AC 109 ms
90,332 KB
testcase_20 AC 112 ms
90,288 KB
testcase_21 AC 89 ms
75,960 KB
testcase_22 AC 88 ms
76,128 KB
testcase_23 AC 87 ms
76,144 KB
testcase_24 AC 80 ms
76,152 KB
testcase_25 AC 88 ms
76,124 KB
testcase_26 AC 84 ms
79,296 KB
testcase_27 AC 105 ms
93,272 KB
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

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