結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー やでな@競プロ
提出日時 2023-10-08 21:14:45
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 159 ms / 2,000 ms
コード長 753 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 82,232 KB
実行使用メモリ 110,192 KB
最終ジャッジ日時 2024-07-26 18:13:04
合計ジャッジ時間 4,287 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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()))

from collections import *
da = defaultdict(int)
db = defaultdict(int)
for i in a:
    da[i] += 1
for i in b:
    db[i] += 1

dp = [False]*(n+1)
dp[0] = True

for i in range(0,n):
    if dp[i] == True:
        if da[i+1] == 0:
            dp[i+1] = True
        if 0 <= i+k <= n:
            if da[i+k] == 0:
                dp[i+k] = True
    elif dp[i] == False:
        if db[i+1] == 1:
            dp[i+1] = True
        if 0 <= i+k <= n:
            if db[i+k] == 1:
                dp[i+k] = True
                
    #print(dp,i)
                
if dp[-1]:
    print("Yes")
else:
    print("No")
            
0