結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-04 21:51:03
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,802 bytes
コンパイル時間 4,936 ms
コンパイル使用メモリ 112,180 KB
実行使用メモリ 33,664 KB
最終ジャッジ日時 2024-05-10 07:18:41
合計ジャッジ時間 6,043 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
19,072 KB
testcase_01 AC 26 ms
18,816 KB
testcase_02 AC 27 ms
18,816 KB
testcase_03 AC 60 ms
25,472 KB
testcase_04 AC 33 ms
20,096 KB
testcase_05 AC 83 ms
33,664 KB
testcase_06 AC 45 ms
22,612 KB
testcase_07 AC 36 ms
20,992 KB
testcase_08 AC 38 ms
21,120 KB
testcase_09 AC 45 ms
22,144 KB
testcase_10 AC 57 ms
24,192 KB
testcase_11 AC 47 ms
23,176 KB
testcase_12 AC 37 ms
20,992 KB
testcase_13 AC 33 ms
19,728 KB
testcase_14 AC 34 ms
19,564 KB
testcase_15 AC 33 ms
19,560 KB
testcase_16 AC 32 ms
19,688 KB
testcase_17 AC 34 ms
19,476 KB
testcase_18 AC 33 ms
19,440 KB
testcase_19 AC 34 ms
19,488 KB
testcase_20 AC 33 ms
19,532 KB
testcase_21 AC 32 ms
19,584 KB
testcase_22 AC 32 ms
19,584 KB
testcase_23 AC 32 ms
19,672 KB
testcase_24 AC 32 ms
19,344 KB
testcase_25 AC 34 ms
19,668 KB
testcase_26 AC 33 ms
19,560 KB
testcase_27 AC 34 ms
19,416 KB
testcase_28 AC 33 ms
19,596 KB
testcase_29 AC 32 ms
19,164 KB
testcase_30 AC 31 ms
19,200 KB
testcase_31 AC 34 ms
19,472 KB
testcase_32 AC 32 ms
19,436 KB
testcase_33 AC 27 ms
19,072 KB
testcase_34 AC 32 ms
19,540 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, k) = (c[0], c[1]);
        var m1 = NN;
        var a = new int[0];
        if (m1 > 0) a = NList;
        else ReadLine();
        var m2 = NN;
        var b = new int[0];
        if (m2 > 0) b = NList;
        else ReadLine();
        var dirty = new bool[n + 1];
        foreach (var ai in a) dirty[ai] = true;
        var clean = new bool[n + 1];
        foreach (var bi in b) clean[bi] = true;
        var dp0 = new bool[n + 1];
        var dp1 = new bool[n + 1];
        dp0[0] = true;
        for (var i = 0; i < n; ++i)
        {
            if (dirty[i + 1])
            {
                dp1[i + 1] |= dp0[i] | dp1[i];
            }
            else if (clean[i + 1])
            {
                dp0[i + 1] |= dp0[i] | dp1[i];
            }
            else
            {
                dp0[i + 1] |= dp0[i];
                dp1[i + 1] |= dp1[i];
            }
            if (i + k <= n)
            {
                if (dirty[i + k])
                {
                    dp1[i + k] |= dp0[i] | dp1[i];
                }
                else if (clean[i + k])
                {
                    dp0[i + k] |= dp0[i] | dp1[i];
                }
                else
                {
                    dp0[i + k] |= dp0[i];
                    dp1[i + k] |= dp1[i];
                }
            }
        }
        WriteLine(dp0[n] ? "Yes" : "No");
    }
}
0