結果
問題 |
No.2021 Not A but B
|
ユーザー |
![]() |
提出日時 | 2022-07-29 22:56:00 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 393 bytes |
コンパイル時間 | 233 ms |
コンパイル使用メモリ | 82,848 KB |
実行使用メモリ | 87,420 KB |
最終ジャッジ日時 | 2024-07-19 16:11:53 |
合計ジャッジ時間 | 2,900 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 WA * 4 |
ソースコード
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 if N == M: ans -= 1 print(ans)