結果
問題 |
No.2021 Not A but B
|
ユーザー |
![]() |
提出日時 | 2022-07-29 22:47:20 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 381 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 82,856 KB |
実行使用メモリ | 93,384 KB |
最終ジャッジ日時 | 2024-07-19 16:00:58 |
合計ジャッジ時間 | 3,246 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | AC * 3 WA * 23 |
ソースコード
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'): print(i) 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)