結果

問題 No.38 赤青白ブロック
ユーザー tktk_snsn
提出日時 2021-01-24 14:23:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,005 ms / 5,000 ms
コード長 581 bytes
コンパイル時間 486 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 76,744 KB
最終ジャッジ日時 2025-01-02 19:15:58
合計ジャッジ時間 26,334 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

r, b = map(int, input().split())
S = input()

ans = 10

for bit in range(1 << 20):
    i = 0
    use = []
    for s in S:
        if s == "W":
            use.append(s)
            continue
        if (bit >> i) & 1:
            use.append(s)
        i += 1

    ok = True
    for i, s in enumerate(use):
        if s == "R" and i + r < len(use) and use[i + r] == "R":
            ok = False
            break
        elif s == "B" and i + b < len(use) and use[i + b] == "B":
            ok = False
            break
    if ok and len(use) > ans:
        ans = len(use)

print(ans)
0