結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
|
提出日時 | 2015-06-07 16:55:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 971 bytes |
コンパイル時間 | 644 ms |
コンパイル使用メモリ | 71,556 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2025-01-03 01:04:09 |
合計ジャッジ時間 | 1,876 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#include <iostream> #include <list> #include <map> #include <numeric> #include <queue> #include <set> #include <sstream> #include <stack> #include <string> #include <utility> #include <vector> #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector<int> VI; typedef pair<int, int> PI; const double EPS=1e-9; int dp[101][1010][11]; int main(void){ int n, d, k; cin >> n >> d >> k; dp[n][0][0] = 1; for (int i = n - 1; i >= 0; --i) { REP(j, 0, d + 1) { REP(l, 0, k + 1) { dp[i][j][l] = dp[i + 1][j][l]; if (j >= i + 1 && l >= 1) { dp[i][j][l] |= dp[i + 1][j - i - 1][l - 1]; } } } } if (dp[0][d][k] == 0) { cout << -1 << endl; return 0; } int cur = d, curk = k; REP (i, 0, n) { if (curk > 0 && dp[i + 1][d - i - 1][curk - 1]) { cout << i + 1; if (curk > 1) { cout << " "; } d -= i + 1; curk--; } } cout << endl; }