結果
問題 |
No.115 遠足のおやつ
|
ユーザー |
|
提出日時 | 2017-06-18 19:25:14 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 1,430 bytes |
コンパイル時間 | 883 ms |
コンパイル使用メモリ | 94,576 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2025-01-03 01:23:36 |
合計ジャッジ時間 | 2,260 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 40 |
ソースコード
#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; }