結果

問題 No.38 赤青白ブロック
ユーザー mkawa2mkawa2
提出日時 2020-01-08 18:31:15
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 809 ms / 5,000 ms
コード長 793 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 7,964 KB
最終ジャッジ日時 2023-08-15 00:43:25
合計ジャッジ時間 12,404 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 355 ms
7,760 KB
testcase_01 AC 573 ms
7,832 KB
testcase_02 AC 353 ms
7,800 KB
testcase_03 AC 354 ms
7,896 KB
testcase_04 AC 353 ms
7,864 KB
testcase_05 AC 353 ms
7,852 KB
testcase_06 AC 356 ms
7,756 KB
testcase_07 AC 353 ms
7,948 KB
testcase_08 AC 351 ms
7,872 KB
testcase_09 AC 362 ms
7,852 KB
testcase_10 AC 354 ms
7,852 KB
testcase_11 AC 352 ms
7,952 KB
testcase_12 AC 354 ms
7,816 KB
testcase_13 AC 354 ms
7,760 KB
testcase_14 AC 351 ms
7,796 KB
testcase_15 AC 352 ms
7,852 KB
testcase_16 AC 370 ms
7,940 KB
testcase_17 AC 355 ms
7,936 KB
testcase_18 AC 359 ms
7,888 KB
testcase_19 AC 364 ms
7,832 KB
testcase_20 AC 359 ms
7,964 KB
testcase_21 AC 356 ms
7,852 KB
testcase_22 AC 809 ms
7,796 KB
testcase_23 AC 353 ms
7,840 KB
testcase_24 AC 365 ms
7,932 KB
testcase_25 AC 352 ms
7,948 KB
testcase_26 AC 358 ms
7,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def MI(): return map(int, sys.stdin.readline().split())

def ok(bit):
    a = []
    for i, c in enumerate(s):
        if c == "R":
            if bit & 1:
                if len(a) >= kr and a[-kr] == 1: return False
                a.append(1)
            bit >>= 1
        elif c == "B":
            if bit & 1:
                if len(a) >= kb and a[-kb] == 2: return False
                a.append(2)
            bit >>= 1
        else:
            a.append(0)
    return True

def main():
    popcut = lambda x: bin(x).count("1")
    ans = 0
    # 1がたっている所を残す
    for bit in range(1 << 20):
        p = popcut(bit)
        if p <= ans: continue
        if ok(bit): ans = p
    print(ans+10)

kr, kb = MI()
s = input()
main()
0