Pagini recente » Cod sursa (job #2357015) | Cod sursa (job #466537) | Cod sursa (job #1173580) | Cod sursa (job #1336283) | Cod sursa (job #2836585)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int n, s, suma, cnt;
int v[105], sol[6];
vector <int> sum;
struct loto
{
int x, y, z;
};
loto aux;
unordered_map <int, loto> m;
int main()
{
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++)
{
suma=v[i]+v[j]+v[k];
aux.x=v[i];
aux.y=v[j];
aux.z=v[k];
sum.push_back(suma);
m[suma]=aux;
}
}
}
cnt=sum.size();
for(int i=0; i<cnt; i++)
{
int aux = sum[i];
if(s-aux>=0 && m.find(s-aux)!=m.end())
{
sol[0] = m[aux].x;
sol[1] = m[aux].y;
sol[2] = m[aux].z;
sol[3] = m[s-aux].x;
sol[4] = m[s-aux].y;
sol[5] = m[s-aux].z;
for(int j=0; j<6; j++)
fout << sol[j] << " ";
return 0;
}
}
fout << -1;
return 0;
}