結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー ThetaTheta
提出日時 2023-10-13 17:11:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,146 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 10,948 KB
実行使用メモリ 820,120 KB
最終ジャッジ日時 2023-10-13 17:12:02
合計ジャッジ時間 8,392 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,976 KB
testcase_01 AC 16 ms
7,860 KB
testcase_02 AC 16 ms
8,028 KB
testcase_03 AC 187 ms
25,232 KB
testcase_04 AC 27 ms
9,832 KB
testcase_05 AC 207 ms
32,980 KB
testcase_06 AC 66 ms
16,300 KB
testcase_07 AC 37 ms
11,780 KB
testcase_08 AC 90 ms
30,156 KB
testcase_09 AC 92 ms
19,148 KB
testcase_10 AC 173 ms
27,888 KB
testcase_11 AC 76 ms
17,376 KB
testcase_12 AC 40 ms
11,636 KB
testcase_13 AC 1,355 ms
472,316 KB
testcase_14 MLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    N, K = map(int, input().split())
    M1 = int(input())
    dirty = set(map(int, input().split()))
    M2 = int(input())
    mats = set(map(int, input().split()))
    dp_table = [[0, 0] for _ in range(N + 1)]
    dp_table[0][0] = 1
    for stair_idx in range(N):
        if stair_idx + 1 in dirty:
            dp_table[stair_idx + 1][1] += sum(dp_table[stair_idx])
        elif stair_idx + 1 in mats:
            dp_table[stair_idx + 1][0] += sum(dp_table[stair_idx])
        else:
            dp_table[stair_idx + 1][0] += dp_table[stair_idx][0]
            dp_table[stair_idx + 1][1] += dp_table[stair_idx][1]
        if stair_idx + K > N:
            continue
        if stair_idx + K in dirty:
            dp_table[stair_idx + K][1] += sum(dp_table[stair_idx])
        elif stair_idx + K in mats:
            dp_table[stair_idx + K][0] += sum(dp_table[stair_idx])
        else:
            dp_table[stair_idx + K][0] += dp_table[stair_idx][0]
            dp_table[stair_idx + K][1] += dp_table[stair_idx][1]

    if dp_table[N][0] > 0:
        print("Yes")
    else:
        print("No")


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