結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー かとぅー ☆かとぅー ☆
提出日時 2023-09-04 22:27:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 1,044 bytes
コンパイル時間 432 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 119,180 KB
最終ジャッジ日時 2023-09-04 22:28:03
合計ジャッジ時間 7,798 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,416 KB
testcase_01 AC 91 ms
71,444 KB
testcase_02 AC 91 ms
71,576 KB
testcase_03 AC 216 ms
108,372 KB
testcase_04 AC 119 ms
77,816 KB
testcase_05 AC 201 ms
119,180 KB
testcase_06 AC 147 ms
85,992 KB
testcase_07 AC 124 ms
78,736 KB
testcase_08 AC 151 ms
83,808 KB
testcase_09 AC 159 ms
92,056 KB
testcase_10 AC 213 ms
105,168 KB
testcase_11 AC 153 ms
93,900 KB
testcase_12 AC 134 ms
79,144 KB
testcase_13 AC 150 ms
78,476 KB
testcase_14 AC 137 ms
78,904 KB
testcase_15 AC 111 ms
78,048 KB
testcase_16 AC 117 ms
77,732 KB
testcase_17 AC 131 ms
78,568 KB
testcase_18 AC 127 ms
78,096 KB
testcase_19 AC 127 ms
78,716 KB
testcase_20 AC 124 ms
78,320 KB
testcase_21 AC 101 ms
77,104 KB
testcase_22 AC 131 ms
78,040 KB
testcase_23 AC 110 ms
77,732 KB
testcase_24 AC 122 ms
78,164 KB
testcase_25 AC 125 ms
78,660 KB
testcase_26 AC 121 ms
77,736 KB
testcase_27 AC 130 ms
78,652 KB
testcase_28 AC 130 ms
78,296 KB
testcase_29 AC 120 ms
77,844 KB
testcase_30 AC 115 ms
77,292 KB
testcase_31 AC 138 ms
78,976 KB
testcase_32 AC 116 ms
77,640 KB
testcase_33 AC 90 ms
71,660 KB
testcase_34 AC 121 ms
78,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

N, K = map(int, input().split())
M_1 = int(input())
A = list(map(int, input().split()))
d_a = defaultdict(int)
for i in range(M_1):
    d_a[A[i]] += 1
M_2 = int(input())        
B = list(map(int, input().split())) 
d_b = defaultdict(int)
for i in range(M_2):
    d_b[B[i]] += 1
dp = [[False, False] for i in range(N + 1)]
dp[0][0] = True   
for i in range(N):
    if dp[i][0]:
        if i+1 <= N:
            if i+1 in d_a:
                dp[i+1][1] = True
            else:
                dp[i+1][0] = True
        if i+K <= N:
            if i+K in d_a:
                dp[i+K][1] = True
            else:
                dp[i+K][0] = True
    if dp[i][1]:
        if i+1 <= N:
            if i+1 in d_b:
                dp[i+1][0] = True      
            else:
                dp[i+1][1] = True       
        if i+K <= N:
            if i+K in d_b:
                dp[i+K][0] = True      
            else:
                dp[i+K][1] = True      

if dp[N][0]:
    print("Yes")
else:
    print("No")
0