結果
| 問題 |
No.2402 Dirty Stairs and Shoes
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-08-04 21:49:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 157 ms / 2,000 ms |
| コード長 | 514 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 82,440 KB |
| 実行使用メモリ | 112,120 KB |
| 最終ジャッジ日時 | 2024-12-20 02:38:39 |
| 合計ジャッジ時間 | 3,798 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
n,k=map(int,input().split())
a=int(input())
A=list(map(int,input().split()))
b=int(input())
B=list(map(int,input().split()))
SA,SB=set(A),set(B)
dp=[[0,0] for _ in range(n+1)]
dp[0][0]=1
dp[0][0]=1
for i in range(n):
if i in SA:
if dp[i][0]:
dp[i][0]=0
dp[i][1]=1
if i in SB:
if dp[i][1]:
dp[i][1]=0
dp[i][0]=1
if dp[i][0]:dp[i+1][0]=1
if dp[i][1]:dp[i+1][1]=1
if i+k<=n:
if dp[i][0]:dp[i+k][0]=1
if dp[i][1]:dp[i+k][1]=1
print("Yes" if dp[n][0] else "No")