Pagini recente » Cod sursa (job #883275) | Cod sursa (job #2466904) | Cod sursa (job #1082252) | Cod sursa (job #3038086) | Cod sursa (job #3143748)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int main()
{
int n, s;
fin >> n >> s;
unordered_map<int,tuple<int,int,int>> f;
vector<int> v(n);
for(int i=0; i<n; i++) fin >> v[i];
for(int i=0; i<n; i++)
for(int j=0; j<n; j++)
for(int k=0; k<n; k++)
f.insert(pair<int,tuple<int,int,int>>(v[i]+v[j]+v[k],tuple<int, int, int>(v[i],v[j],v[k])));
for(unordered_map<int, tuple<int,int,int>>::iterator it = f.begin(); it != f.end(); it++)
{
if(f.find(s-(it->first))!=f.end())
{
fout << get<0>(it->second) << ' ' << get<1>(it->second) << ' ' << get<2>(it->second) << ' ' << get<0>(f.find(s-(it->first))->second) << ' ' << get<1>(f.find(s-(it->first))->second) << ' ' << get<2>(f.find(s-(it->first))->second);
return 0;
}
}
fout << -1;
return 0;
}