結果

問題 No.2402 Dirty Stairs and Shoes
コンテスト
ユーザー detteiuu
提出日時 2025-03-02 23:53:51
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 108 ms / 2,000 ms
+ 899µs
コード長 658 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 64,512 KB
実行使用メモリ 84,276 KB
最終ジャッジ日時 2026-11-30 19:56:29
合計ジャッジ時間 5,109 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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]*2 for _ in range(N+1)]
dp[0][0] = True
for i in range(N):
    for j in range(2):
        if not dp[i][j]:
            continue
        if i+1 in A:
            dp[i+1][1] = True
        elif i+1 in B:
            dp[i+1][0] = True
        else:
            dp[i+1][j] = True
        if i+K <= N:
            if i+K in A:
                dp[i+K][1] = True
            elif i+K in B:
                dp[i+K][0] = True
            else:
                dp[i+K][j] = True

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