Pagini recente » Cod sursa (job #2866420) | Cod sursa (job #1448477) | Cod sursa (job #1241777) | Cod sursa (job #3126689) | Cod sursa (job #2783555)
#include <iostream>
#include <unordered_map>
#include <fstream>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
pair <int , int> c;
pair <int, pair<int,int> > d;
unordered_map <int , pair<int , pair<int,int> > > H;
int main()
{
long long n,s,V[100],a = 1,ok = 0;
fin>>n>>s;
for(int i = 1;i<=n;++i)
{
fin>>V[i];
}
for(int i = 1;i<=n;++i)
{
for(int j = 1;j<=n;++j)
{
for(int k = 1;k<=n;++k)
{
c.first = V[j];
c.second = V[k];
d.first = V[i];
d.second = c;
H[V[i]+V[j]+V[k]] = d;
a++;
}
}
}
for(auto it: H)
{
if(H.find(s - it.first) != H.end())
{
ok = 1;
pair<int,pair<int,int> > pr = H[s-it.first];
fout<<pr.first<<' '<<pr.second.first<<' '<<pr.second.second<<' ';
fout<<it.second.first<<' '<<it.second.second.first<<' '<<it.second.second.second;
return 0;
}
}
if(ok == 0)
fout<<-1;
}