結果
| 問題 |
No.38 赤青白ブロック
|
| コンテスト | |
| ユーザー |
ckawatak
|
| 提出日時 | 2019-03-03 22:46:57 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 988 ms / 5,000 ms |
| コード長 | 747 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 81,792 KB |
| 実行使用メモリ | 76,544 KB |
| 最終ジャッジ日時 | 2024-06-23 13:19:03 |
| 合計ジャッジ時間 | 25,200 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 |
ソースコード
KR,KB = list(map(int, input().split(' ')))
S = input()
position = [0 for _ in range(len(S))]
p = 0
for i in range(len(S)):
if S[i] == 'W':
position[i] = 21
else:
position[i] = p
p = p + 1
length = 0
# check the removal patterns of 2**20
for i in range(1<<20):
t = []
yes = True
for j in range(len(S)):
# remove the character at position[j] and check the condition
if i & (1 << position[j]) == 0:
t.append(S[j])
if S[j] == 'R' and KR < len(t) and t[len(t)-KR-1] == 'R':
yes = False
if S[j] == 'B' and KB < len(t) and t[len(t)-KB-1] == 'B':
yes = False
if yes:
length = max(length, len(t))
print(length)
ckawatak