結果

問題 No.115 遠足のおやつ
ユーザー llllll
提出日時 2018-04-21 03:30:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,025 bytes
コンパイル時間 791 ms
コンパイル使用メモリ 97,860 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-09-09 12:16:31
合計ジャッジ時間 15,106 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

int N, D, K;

void dfs(vector<int> &v, int sum, int cur) {
    if (v.size() == K) {
        if (sum == D) {
            for (int i = 0; i < v.size(); i++) {
                if (i > 0)
                    cout << " ";
                cout << v[i];
            }
            cout << endl;
            exit(0);
        }
        return;
    }

    for (int n = cur; n <= N; n++) {
        v.push_back(n);
        if (sum + n > D) {
            v.pop_back();
            return;
        }
        dfs(v, sum + n, n + 1);
        v.pop_back();
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    // int N, D, K;
    cin >> N >> D >> K;

    vector<int> v;
    dfs(v, 0, 1);
    cout << -1 << endl;

    return 0;
}
0