結果
問題 |
No.2402 Dirty Stairs and Shoes
|
ユーザー |
|
提出日時 | 2023-10-13 17:12:51 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,146 bytes |
コンパイル時間 | 1,064 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 849,020 KB |
最終ジャッジ日時 | 2024-09-15 13:08:52 |
合計ジャッジ時間 | 6,253 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 11 MLE * 1 -- * 20 |
ソースコード
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()