結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー mattu34mattu34
提出日時 2023-09-08 00:57:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 918 bytes
コンパイル時間 1,383 ms
コンパイル使用メモリ 86,488 KB
実行使用メモリ 106,460 KB
最終ジャッジ日時 2023-09-08 00:57:23
合計ジャッジ時間 7,009 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,828 KB
testcase_01 AC 94 ms
71,756 KB
testcase_02 AC 86 ms
71,532 KB
testcase_03 AC 186 ms
96,148 KB
testcase_04 AC 134 ms
78,640 KB
testcase_05 AC 204 ms
106,460 KB
testcase_06 AC 144 ms
87,332 KB
testcase_07 AC 156 ms
80,624 KB
testcase_08 AC 150 ms
82,928 KB
testcase_09 AC 161 ms
88,964 KB
testcase_10 AC 194 ms
94,724 KB
testcase_11 AC 146 ms
87,828 KB
testcase_12 AC 138 ms
80,424 KB
testcase_13 AC 137 ms
89,620 KB
testcase_14 AC 147 ms
96,568 KB
testcase_15 AC 122 ms
79,536 KB
testcase_16 AC 114 ms
78,680 KB
testcase_17 AC 142 ms
92,120 KB
testcase_18 AC 132 ms
88,132 KB
testcase_19 AC 150 ms
94,548 KB
testcase_20 AC 144 ms
91,508 KB
testcase_21 AC 105 ms
77,552 KB
testcase_22 AC 122 ms
79,144 KB
testcase_23 AC 123 ms
78,712 KB
testcase_24 AC 128 ms
78,776 KB
testcase_25 AC 147 ms
93,904 KB
testcase_26 AC 123 ms
78,880 KB
testcase_27 AC 148 ms
94,792 KB
testcase_28 AC 142 ms
89,644 KB
testcase_29 AC 121 ms
79,008 KB
testcase_30 AC 109 ms
78,024 KB
testcase_31 AC 156 ms
95,324 KB
testcase_32 AC 118 ms
78,936 KB
testcase_33 AC 90 ms
71,504 KB
testcase_34 AC 118 ms
78,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
import heapq
import bisect
import itertools


INF = float("inf")
MOD = 998244353
mod = 998244353

N, K = map(int, input().split())
M = int(input())
A = list(map(int, input().split()))
state = [0] * (N + 1)
for a in A:
    state[a] = -1
M = int(input())
B = list(map(int, input().split()))
for b in B:
    state[b] = 1

dp = [[False] * 2 for _ in range(N + 1)]
dp[0][0] = True
for i in range(N):
    for j in range(2):
        if state[i + 1] == 0:
            dp[i + 1][j] |= dp[i][j]
        elif state[i + 1] == 1:
            dp[i + 1][0] |= dp[i][j]
        else:
            dp[i + 1][1] |= dp[i][j]

        if i + K <= N:
            if state[i + K] == 0:
                dp[i + K][j] |= dp[i][j]
            elif state[i + K] == 1:
                dp[i + K][0] |= dp[i][j]
            else:
                dp[i + K][1] |= dp[i][j]
if dp[N][0]:
    print("Yes")
else:
    print("No")
0