結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー グミグミ
提出日時 2023-08-04 21:42:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 93 ms / 2,000 ms
コード長 453 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 82,072 KB
実行使用メモリ 100,084 KB
最終ジャッジ日時 2024-12-20 02:32:06
合計ジャッジ時間 3,055 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
	n,k=map(int,input().split())
	m1=int(input())
	a=set(map(int,input().split()))
	m2=int(input())
	b=set(map(int,input().split()))
	
	dp=[False]*(n+1)
	dp[0]=True

	for i in range(1,n+1):
		if i in a:
			dp[i] = False
		elif i in b:
			dp[i] = True
		elif dp[i-1]:
			dp[i] = True
		elif 0 <= i-k < n+1:
			if dp[i-k]:
				dp[i] = True
		else:
			dp[i] = False
	
	ans = dp[n]
	print('Yes' if ans else 'No')

if __name__ == "__main__":
	main()
0