結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー Navier_Boltzmann
提出日時 2023-08-05 17:19:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 438 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 82,392 KB
実行使用メモリ 233,648 KB
最終ジャッジ日時 2024-12-20 02:49:06
合計ジャッジ時間 6,762 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

# import pypyjit
# pypyjit.set_param('max_unroll_recursion=-1')
from collections import *
from itertools import *
from functools import *
from heapq import *
import sys,math
sys.setrecursionlimit(10**6)
# input = sys.stdin.readline

N,K = map(int,input().split())

M1 = int(input())
if M1!=0:
    A = list(map(int,input().split()))
else:
    A = set([])
M2 = int(input())
if M2!=0:
    B = list(map(int,input().split()))
else:
    B = set([])
B =set(B)
A = set(A)
dp = [-1]*(N+1)
dp[0]=1
def f(x):
    if dp[x]!=-1:
        return dp[x]
    if x in A:
        dp[x] = 0
        return dp[x]
    if x in B:
        dp[x] = 1
        return 1
    if x>=K:
        dp[x] = max(f(x-1),f(x-K))
        return dp[x]
    dp[x] = f(x-1)
    return dp[x]
if f(N):
    print('Yes')
else:
    print('No')
0