結果

問題 No.38 赤青白ブロック
ユーザー Mao-betaMao-beta
提出日時 2024-03-01 01:36:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,295 ms / 5,000 ms
コード長 1,345 bytes
コンパイル時間 446 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 76,688 KB
最終ジャッジ日時 2024-03-01 01:36:49
合計ジャッジ時間 30,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 888 ms
76,536 KB
testcase_01 AC 1,228 ms
76,208 KB
testcase_02 AC 1,061 ms
76,324 KB
testcase_03 AC 1,131 ms
76,456 KB
testcase_04 AC 1,098 ms
76,452 KB
testcase_05 AC 759 ms
76,528 KB
testcase_06 AC 1,134 ms
76,460 KB
testcase_07 AC 1,126 ms
76,452 KB
testcase_08 AC 803 ms
76,528 KB
testcase_09 AC 1,129 ms
76,196 KB
testcase_10 AC 775 ms
76,268 KB
testcase_11 AC 828 ms
76,520 KB
testcase_12 AC 917 ms
76,312 KB
testcase_13 AC 744 ms
76,524 KB
testcase_14 AC 989 ms
76,308 KB
testcase_15 AC 931 ms
76,180 KB
testcase_16 AC 1,144 ms
76,196 KB
testcase_17 AC 951 ms
76,688 KB
testcase_18 AC 799 ms
76,524 KB
testcase_19 AC 1,004 ms
76,180 KB
testcase_20 AC 1,081 ms
76,448 KB
testcase_21 AC 1,169 ms
76,324 KB
testcase_22 AC 1,150 ms
76,432 KB
testcase_23 AC 843 ms
76,528 KB
testcase_24 AC 1,295 ms
76,204 KB
testcase_25 AC 945 ms
76,448 KB
testcase_26 AC 972 ms
76,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import math
import bisect
from heapq import heapify, heappop, heappush
from collections import deque, defaultdict, Counter
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD99 = 998244353

input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()
SMI = lambda: input().split()
SLI = lambda: list(SMI())
EI = lambda m: [NLI() for _ in range(m)]


def main():
    Kr, Kb = NMI()
    S = SI()

    ans = 0
    for case in range(1<<20):
        T = []
        d = 0
        for s in S:
            if s == "W":
                T.append(s)
            else:
                if (case >> d) & 1:
                    T.append(s)
                d += 1
        ok = True
        M = len(T)

        for i in range(M):
            j = i + Kr
            if j >= M:
                break
            if T[i] == T[j] == "R":
                ok = False

        for i in range(M):
            j = i + Kb
            if j >= M:
                break
            if T[i] == T[j] == "B":
                ok = False

        if ok:
            if M > ans:
                ans = max(ans, M)

    print(ans)


if __name__ == "__main__":
    main()
0