-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathIP_AMAZON.cpp
More file actions
84 lines (74 loc) · 1.98 KB
/
IP_AMAZON.cpp
File metadata and controls
84 lines (74 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define loop(i, start, end) for (int i = start; i <= end; i++)
#define rloop(i, start, end) for (int i = start; i >= end; i--)
#define vi vector<int>
#define vec(x) vector<x>
#define sz(v) (int)v.size()
#define UB upper_bound
#define LB lower_bound
#define all(v) (v).begin(),(v).end()
#define arl(v) (v).rbegin(),(v).rend()
#define fsp(a) fixed<<setprecision(a)
#define mem(a,with) memset(a, with, sizeof (a))
#define vmn(a) (*min_element(a.begin(),a.end()))
#define vmx(a) (*max_element(a.begin(),a.end()))
#define bs(a,key) binary_search(all(a),key) /// return bool.
#define rotl(a,x) rotate(a.begin(),a.begin()+x,a.end());
#define rotr(a,x) rotl(a,a.size()-x);
#define nl cout<<endl
#define dbg(x) cerr << #x << " :: " << x << endl;
#define dbg2(x, y) cerr << #x << " :: " << x << "\t" << #y << " :: " << y << endl;
#define MOD 1000000007
int add(int x, int y) {int res = x + y; return (res >= MOD ? res - MOD : res);}
int mul(int x, int y) {int res = x * y; return (res >= MOD ? res % MOD : res);}
int power(int x, int y) {int res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
vector<vi> ans;
vi arr,temp;
int n,k;
void f(int idx,int sum){
if(sum==k){
ans.push_back(temp);
return;
}
if(idx>=n or sum>k) return;
f(idx+1,sum);
temp.push_back(arr[idx]);
f(idx+2,sum+arr[idx]);
temp.pop_back();
}
void solve(){
//code goes here
cin>>n>>k;
arr.resize(n);
loop(i,0,n-1) cin>>arr[i];
f(0,0);
if(ans.size()==0){
cout<<-1;
return;
}
for(auto it:ans){
for(auto x:it){
cout<<x<<" ";
}
nl;
}
}
int32_t main()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
int t=1;
// cin>>t;
while (t--)
{
solve();
}
return 0;
}