Pagini recente » Cod sursa (job #2315799) | Cod sursa (job #2481191) | Cod sursa (job #2483637) | Cod sursa (job #269901) | Cod sursa (job #2954728)
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define dbg(x) cout << #x <<": " << x << "\n";
#define sz(x) ((int)x.size())
using ll = long long;
const string fn = "loto";
ifstream fin(fn + ".in");
ofstream fout(fn + ".out");
const int mxn = 100;
const int oo = 2e9;
int n, s;
int a[mxn + 5];
map<int, pair<int, int> > m;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie();
fin >> n >> s;
for(int i = 1; i <= n; ++i)
fin >> a[i];
for(int i = 1; i <= n; ++i)
for(int j = i; j <= n; ++j)
for(int k = j; k <= n; ++k){
if(a[i] + a[j] + a[k] <= s){
m[a[i] + a[j] + a[k]] = {a[i], a[j]};
if(m.find(s - a[i] - a[j] - a[k])!= m.end()){
fout << a[i] << ' ' << a[j] << ' ' << a[k] << ' ' << m[s - a[i] - a[j] - a[k]].first << ' ' << m[s - a[i] - a[j] - a[k]].second << ' ' << s - a[i] - a[j] - a[k] - m[s - a[i] - a[j] - a[k]].first - m[s - a[i] - a[j] - a[k]].second << '\n';
return 0;
}
}
}
fout << "-1";
return 0;
}