結果
問題 | No.2402 Dirty Stairs and Shoes |
ユーザー |
![]() |
提出日時 | 2025-03-02 23:53:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 163 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 552 ms |
コンパイル使用メモリ | 81,968 KB |
実行使用メモリ | 107,740 KB |
最終ジャッジ日時 | 2025-03-02 23:53:57 |
合計ジャッジ時間 | 5,376 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
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")