結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
![]() |
提出日時 | 2018-04-10 18:46:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 67 ms / 5,000 ms |
コード長 | 1,302 bytes |
コンパイル時間 | 1,206 ms |
コンパイル使用メモリ | 97,740 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-03 01:28:20 |
合計ジャッジ時間 | 3,041 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <algorithm> #include <cmath> #include <cstring> #include <deque> #include <iostream> #include <map> #include <numeric> #include <queue> #include <set> #include <string> #include <unordered_map> #include <vector> using namespace std; using ll = long long; const int inf = 1e9; void display(vector<int> &v) { for (auto e : v) { cout << e << " "; } cout << endl; } int main() { cin.tie(0); ios::sync_with_stdio(false); int N, D, K; cin >> N >> D >> K; vector<int> dp[15][1015]; for (int i = 0; i < 15; i++) { for (int j = 0; j < 1015; j++) { dp[i][j] = {inf}; } } dp[0][0] = {}; for (int n = 1; n <= N; n++) { for (int j = D; j >= 0; j--) { if (j - n < 0) continue; for (int i = 0; i < K; i++) { vector<int> tmp = dp[i][j - n]; tmp.push_back(n); if (dp[i + 1][j] > tmp) { dp[i + 1][j] = tmp; } } } } if (dp[K][D][0] != inf) { for (int i = 0; i < K; i++) { if (i > 0) cout << " "; cout << dp[K][D][i]; } cout << endl; } else { cout << -1 << endl; } return 0; }