結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー komkompi
提出日時 2023-08-05 07:28:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 114 ms / 2,000 ms
コード長 534 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 82,396 KB
実行使用メモリ 109,748 KB
最終ジャッジ日時 2024-12-20 02:47:56
合計ジャッジ時間 3,418 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
# Your code here!
N,K=map(int,input().split())
M1=int(input())
A=list(map(int,input().split()))

M2=int(input())
B=list(map(int,input().split()))

stairs=[10**9]*(N+1)
stairs[0]=0

A=set(A)
B=set(B)

for i in range(N):
    for delta in [1,K]:
        nxt=i+delta
        if nxt>N:
            continue
        if nxt in A:
            stairs[nxt]=1
        elif nxt in B:
            stairs[nxt]=0
        else:
            stairs[nxt]=min(stairs[i],stairs[nxt])

if stairs[-1]:
    print("No")
else:
    print("Yes")
0