結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー Akijin_007
提出日時 2023-08-04 21:33:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 484 bytes
コンパイル時間 378 ms
コンパイル使用メモリ 82,556 KB
実行使用メモリ 92,964 KB
最終ジャッジ日時 2024-12-20 02:27:41
合計ジャッジ時間 3,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map(int, input().split())
M1 = int(input())
A = list(map(int, input().split()))
M2 = int(input())
B = list(map(int, input().split()))

dp = [0] * (N+1)
a = [-1] * (N+1)

for i in range(M1):
    a[A[i]] = 0
for i in range(M2):
    a[B[i]] = 1

dp[0] = 1
for i in range(1, N+1):
    if a[i] != -1:
        dp[i] = a[i]
        continue

    if i-K < 0:
        dp[i] = dp[i-1]
    else:
        dp[i] = max(dp[i-1], dp[i-K])

if dp[N] == 0:
    print("No")
else:
    print("Yes")
0