結果

問題 No.115 遠足のおやつ
ユーザー tonyu0
提出日時 2020-03-29 22:11:11
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 609 bytes
コンパイル時間 1,070 ms
コンパイル使用メモリ 99,508 KB
最終ジャッジ日時 2025-01-09 10:52:48
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using ll = long long;
using namespace std;
constexpr ll INF = 1LL << 60;

int N, D, K;
string dp[1010][10];

int main() {
	cin >> N >> D >> K;
	dp[0][0] = "0";
	for (int i = 1; i < N + 1; ++i) {
		for (int j = 0; j < N + 1; ++j) {
			for (int k = 0; k < K; ++k) {
				if (dp[j][k] == "" || dp[j][k].back() == (char)(i + '0')) continue;
				dp[i + j][k + 1] = dp[j][k] + " " + to_string(i);
			}
		}
	}
	if (dp[D][K] == "") cout << -1;
	else cout << dp[D][K].substr(2);
	cout << endl;
	return 0;
}
0