結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー imo1imo1
提出日時 2023-08-04 22:43:05
言語 C
(gcc 12.3.0)
結果
TLE  
実行時間 -
コード長 6,770 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 30,336 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-05-10 07:22:32
合計ジャッジ時間 4,192 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <stdio.h>

int N, K, M1, A[200001], M2, B[200001];

int ans(int n)
{
    if (n == 1 || n == 0) {
        return 1;
    }

    int i, j, flag1 = 1, flag2 = 1;
    for (i = 1; i <= M2; i++) {
        if (B[i] == n - K || B[i] == n - 1) {
            return 1;
        }
    }

    for (i = 1; i <= M1; i++) {
        if (A[i] == n - K || n - K < 0) flag1 = 0;
        if (A[i] == n - 1) flag2 = 0;
    }

    if (flag1 == 1 && flag2 == 1) return ans(n - K) + ans(n - 1);
    else if (flag1 == 1) return ans(n - K);
    else if (flag2 == 1) return ans(n - 1);
    else return 0;
}

int main()                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
{
    int i, sum = 0;
    scanf("%d %d", &N, &K);
    scanf("%d", &M1);
    for (i = 1; i <= M1; i++) scanf("%d", &A[i]);
    scanf("%d", &M2);
    for (i = 1; i <= M2; i++) scanf("%d", &B[i]);

    if (ans(N)) printf("Yes\n");
    else printf("No\n");

    return 0;
}
0