結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー InTheBloomInTheBloom
提出日時 2023-08-04 21:35:45
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 1,003 bytes
コンパイル時間 6,287 ms
コンパイル使用メモリ 210,252 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-20 02:28:49
合計ジャッジ時間 7,539 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,824 KB
testcase_01 AC 1 ms
6,816 KB
testcase_02 AC 1 ms
6,820 KB
testcase_03 AC 15 ms
6,820 KB
testcase_04 AC 3 ms
6,816 KB
testcase_05 AC 23 ms
6,820 KB
testcase_06 AC 8 ms
6,816 KB
testcase_07 AC 4 ms
6,820 KB
testcase_08 AC 5 ms
6,816 KB
testcase_09 AC 8 ms
6,820 KB
testcase_10 AC 13 ms
6,820 KB
testcase_11 AC 9 ms
6,820 KB
testcase_12 AC 4 ms
6,820 KB
testcase_13 AC 2 ms
6,816 KB
testcase_14 AC 3 ms
6,820 KB
testcase_15 AC 2 ms
6,816 KB
testcase_16 AC 2 ms
6,820 KB
testcase_17 AC 3 ms
6,820 KB
testcase_18 AC 2 ms
6,820 KB
testcase_19 AC 3 ms
6,816 KB
testcase_20 AC 3 ms
6,816 KB
testcase_21 AC 2 ms
6,816 KB
testcase_22 AC 2 ms
6,816 KB
testcase_23 AC 2 ms
6,816 KB
testcase_24 AC 2 ms
6,820 KB
testcase_25 AC 3 ms
6,816 KB
testcase_26 AC 2 ms
6,816 KB
testcase_27 AC 3 ms
6,816 KB
testcase_28 AC 3 ms
6,820 KB
testcase_29 AC 2 ms
6,816 KB
testcase_30 AC 1 ms
6,820 KB
testcase_31 AC 3 ms
6,816 KB
testcase_32 AC 2 ms
6,816 KB
testcase_33 AC 1 ms
6,820 KB
testcase_34 AC 2 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main () {
    int N, K; readf("%d %d ", N, K);
    int M1 = readln.chomp.to!int;
    int[] A = readln.split.to!(int[]);
    int M2 = readln.chomp.to!int;
    int[] B = readln.split.to!(int[]);

    solve(N, K, M1, A, M2, B);
}

void solve (int N, int K, int M1, int[] A, int M2, int[] B) {
    int[] stairs = new int[](N+1);
    // 1 -> 靴ふきマット | 2 -> 汚れ

    foreach (b; B) {
        stairs[b] = 1;
    }
    foreach (a; A) {
        stairs[a] = 2;
    }

    bool[] dp = new bool[](N+1);
    // dp[i] := i段目に綺麗な状態で行けるか?

    // initialize
    dp[0] = true;

    foreach (i; 1..N+1) {
        if (0 <= i-K && dp[i-K]) {
            dp[i] = true;
        }
        if (dp[i-1]) {
            dp[i] = true;
        }

        if (stairs[i] == 1) {
            dp[i] = true;
        }
        if (stairs[i] == 2) {
            dp[i] = false;
        }
    }

    if (dp[N]) {
        writeln("Yes");
    } else {
        writeln("No");
    }
}
0