結果

問題 No.115 遠足のおやつ
ユーザー zuvizudarzuvizudar
提出日時 2017-06-18 19:25:14
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 5,000 ms
コード長 1,430 bytes
コンパイル時間 805 ms
コンパイル使用メモリ 90,216 KB
実行使用メモリ 8,004 KB
最終ジャッジ日時 2023-08-31 00:44:06
合計ジャッジ時間 2,413 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,784 KB
testcase_01 AC 4 ms
7,712 KB
testcase_02 AC 4 ms
7,900 KB
testcase_03 AC 5 ms
7,988 KB
testcase_04 AC 6 ms
7,692 KB
testcase_05 AC 5 ms
8,000 KB
testcase_06 AC 4 ms
7,744 KB
testcase_07 AC 4 ms
7,952 KB
testcase_08 AC 4 ms
7,752 KB
testcase_09 AC 4 ms
7,992 KB
testcase_10 AC 5 ms
7,736 KB
testcase_11 AC 4 ms
7,692 KB
testcase_12 AC 4 ms
7,688 KB
testcase_13 AC 4 ms
7,756 KB
testcase_14 AC 5 ms
7,784 KB
testcase_15 AC 6 ms
7,736 KB
testcase_16 AC 7 ms
7,688 KB
testcase_17 AC 6 ms
7,748 KB
testcase_18 AC 5 ms
7,736 KB
testcase_19 AC 5 ms
7,684 KB
testcase_20 AC 4 ms
7,780 KB
testcase_21 AC 4 ms
7,704 KB
testcase_22 AC 5 ms
7,676 KB
testcase_23 AC 4 ms
7,804 KB
testcase_24 AC 5 ms
7,672 KB
testcase_25 AC 7 ms
7,960 KB
testcase_26 AC 4 ms
7,808 KB
testcase_27 AC 5 ms
8,004 KB
testcase_28 AC 4 ms
7,760 KB
testcase_29 AC 5 ms
7,684 KB
testcase_30 AC 5 ms
7,796 KB
testcase_31 AC 5 ms
7,808 KB
testcase_32 AC 7 ms
7,756 KB
testcase_33 AC 5 ms
7,792 KB
testcase_34 AC 7 ms
7,748 KB
testcase_35 AC 4 ms
7,760 KB
testcase_36 AC 5 ms
7,784 KB
testcase_37 AC 6 ms
7,712 KB
testcase_38 AC 8 ms
7,780 KB
testcase_39 AC 8 ms
7,740 KB
testcase_40 AC 4 ms
7,692 KB
testcase_41 AC 4 ms
7,900 KB
testcase_42 AC 4 ms
7,708 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

int N,D,K;
int dp[101][1001][11];
vector<int>now;
vector<int>ans;

int solve(int a,int b,int c){				//n,d,k
	if(dp[a][b][c]!=-1)return dp[a][b][c];
	if(c==K){
		if(b==D){
			if(ans.size()==0)
			ans=now;
			return 1;
		}
		else{
			return 0;
		}
	}
	if(a==N)
		return 0;
	
	int ret=0;
	now.push_back(a+1);
	int use=solve(a+1,b+(a+1),c+1);
	now.pop_back();
	int not_use=solve(a+1,b,c);
	ret=(use||not_use);
	return dp[a][b][c]=ret;

}
int main(){
	cin>>N>>D>>K;
	fill((int*)dp,(int*)dp+101*1001*11,-1);
	if(solve(0,0,0)){
		for(int i=0;i<ans.size();i++)
			cout<<ans[i]<<" ";

		cout<<endl;
	}
	else
		cout<<"-1"<<endl;

	return 0;
}
0