結果
問題 |
No.2402 Dirty Stairs and Shoes
|
ユーザー |
![]() |
提出日時 | 2023-08-05 02:15:13 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 108 ms / 2,000 ms |
コード長 | 626 bytes |
コンパイル時間 | 242 ms |
コンパイル使用メモリ | 82,540 KB |
実行使用メモリ | 93,908 KB |
最終ジャッジ日時 | 2024-12-20 02:47:23 |
合計ジャッジ時間 | 3,246 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
N,K = map(int,input().split()) M1 = int(input()) A = list(map(int,input().split())) A.sort() M2 = int(input()) B = list(map(int,input().split())) B.sort() #dp[i]=i段目にきれいな状態で着地できるか? dp = [False]*(N+1) dp[0] = True now_dirty = 0 now_clean = 0 for i in range(1,N+1): if now_dirty <= M1-1 and i == A[now_dirty]: now_dirty += 1 elif now_clean <= M2-1 and i == B[now_clean]: now_clean += 1 dp[i] = True else: if dp[i-1]: dp[i] = True elif i >= K and dp[i-K]: dp[i] = True if dp[N]: print("Yes") else: print("No")