結果

問題 No.115 遠足のおやつ
ユーザー くれちーくれちー
提出日時 2017-02-22 17:19:35
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 873 bytes
コンパイル時間 291 ms
コンパイル使用メモリ 25,100 KB
実行使用メモリ 6,044 KB
最終ジャッジ日時 2023-08-29 01:26:30
合計ジャッジ時間 9,998 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 259 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 0 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 90 ms
4,380 KB
testcase_16 AC 18 ms
4,376 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 0 ms
4,376 KB
testcase_19 AC 0 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 0 ms
4,376 KB
testcase_22 AC 1,806 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define rep(i, n) for (i = 0; i < n; i++)
#define rrep(i, n) for (i = n; i >= 0; i--)
#define max(a, b) (a > b ? a : b)
#define min(a, b) (a < b ? a : b)
typedef long long ll;

int n, d, k;
bool buy[101];

bool dfs(int idx, int sum, int cnt) {
    if (sum == d && cnt == k) return true;
    if (sum > d) return false;
    if (cnt > k) return false;
    if (idx > n) return false;

    if (dfs(idx + 1, sum + idx, cnt + 1)) {
        buy[idx] = true;
        return true;
    }
    if (dfs(idx + 1, sum, cnt)) {
        buy[idx] = false;
        return true;
    }
    return false;
}

int main() {
    scanf("%d %d %d", &n, &d, &k);

    int i;
    if (dfs(1, 0, 0)) {
        rep(i, n + 1) { if (buy[i + 1]) printf("%d ", i + 1); }
    }
    else puts("-1");
    return 0;
}
0