結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2018-04-21 03:23:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 951 bytes |
コンパイル時間 | 916 ms |
コンパイル使用メモリ | 101,260 KB |
実行使用メモリ | 10,016 KB |
最終ジャッジ日時 | 2024-06-27 05:19:52 |
合計ジャッジ時間 | 7,968 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 TLE * 1 -- * 24 |
ソースコード
#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 cur) { if (v.size() == K) { if (accumulate(v.begin(), v.end(), 0) == 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); dfs(v, 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, 1); cout << -1 << endl; return 0; }