Pagini recente » Cod sursa (job #2462343) | Cod sursa (job #1730169) | Cod sursa (job #2340079) | Cod sursa (job #185818) | Cod sursa (job #2981838)
#include <fstream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <tuple>
using namespace std;
ifstream cin("loto.in");
ofstream cout("loto.out");
int main()
{
int n,s;
cin>>n>>s;
vector<int>v(n);
vector<tuple<int,int,int> >half;
unordered_map<int,tuple<int,int,int> >m;
for(int i=0;i<n;i++)
{
cin>>v[i];
}
for(int i=0;i<n;i++)
{
for(int j=i;j<n;j++)
{
for(int k=j;k<n;k++)
{
half.push_back(make_tuple(v[i],v[j],v[k]));
m[v[i]+v[j]+v[k]]=make_tuple(v[i],v[j],v[k]);
}
}
}
for(int i=0;i<half.size();i++)
{
int left=s-(get<0>(half[i])+get<1>(half[i])+get<2>(half[i]));
if(m.count(left))
{
cout<<get<0>(half[i])<<" "<<get<1>(half[i])<<" "<<get<2>(half[i])<<" ";
cout<<get<0>(m[left])<<" "<<get<1>(m[left])<<" "<<get<2>(m[left]);
return 0;
}
}
cout<<"-1";
return 0;
}