結果

問題 No.2402 Dirty Stairs and Shoes
コンテスト
ユーザー flippergo
提出日時 2026-04-21 08:49:01
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 773 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 262 ms
コンパイル使用メモリ 85,760 KB
実行使用メモリ 114,816 KB
最終ジャッジ日時 2026-04-21 08:49:09
合計ジャッジ時間 4,437 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,K = map(int,input().split())
M1 = int(input())
A = set(list(map(int,input().split())))
M2 = int(input())
B = set(list(map(int,input().split())))
dp = [False]*(N+1)
dp[0] = True
for i in range(1,N+1):
    if i in B:
        dp[i] = True
    elif i not in A:
        if i-1 in B:
            dp[i] = True
        elif i-1 in A:
            dp[i] = False
            if  i>=K:
                dp[i] = dp[i-K]
        else:
            dp[i] = dp[i-1]
            if i>=K:
                dp[i] = dp[i]|dp[i-K]
        if i>=K and i-K in B:
            dp[i] = True
        elif i>=K and i-K in A:
            dp[i] = dp[i-1]
        else:
            dp[i] = dp[i-1]
            if i>=K:
                dp[i] = dp[i]|dp[i-K]
if dp[N]:
    print("Yes")
else:
    print("No")
0