結果

問題 No.115 遠足のおやつ
コンテスト
ユーザー tonyu0
提出日時 2020-03-29 22:11:11
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 609 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 860 ms
コンパイル使用メモリ 116,212 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-09 05:04:16
合計ジャッジ時間 2,353 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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