結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー Theta
提出日時 2023-10-13 17:11:53
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
MLE  
実行時間 -
コード長 1,146 bytes
コンパイル時間 314 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 820,992 KB
最終ジャッジ日時 2024-09-15 13:07:26
合計ジャッジ時間 5,812 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 MLE * 1 -- * 20
権限があれば一括ダウンロードができます

ソースコード

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