結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー ThetaTheta
提出日時 2023-10-13 17:12:51
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,146 bytes
コンパイル時間 1,624 ms
コンパイル使用メモリ 86,708 KB
実行使用メモリ 843,328 KB
最終ジャッジ日時 2023-10-13 17:13:00
合計ジャッジ時間 7,955 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
71,168 KB
testcase_01 AC 63 ms
71,484 KB
testcase_02 AC 64 ms
71,292 KB
testcase_03 AC 210 ms
98,472 KB
testcase_04 AC 105 ms
78,468 KB
testcase_05 AC 179 ms
106,280 KB
testcase_06 AC 112 ms
88,988 KB
testcase_07 AC 107 ms
79,560 KB
testcase_08 AC 218 ms
98,640 KB
testcase_09 AC 134 ms
89,616 KB
testcase_10 AC 351 ms
100,024 KB
testcase_11 AC 117 ms
89,200 KB
testcase_12 AC 111 ms
80,352 KB
testcase_13 AC 702 ms
500,280 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