Pagini recente » Cod sursa (job #330973) | Cod sursa (job #1647351) | Cod sursa (job #1166778) | Cod sursa (job #1431195) | Cod sursa (job #2835791)
#include <fstream>
#include <unordered_map>
using namespace std;
ifstream cin("loto.in");
ofstream cout("loto.out");
struct sol
{
int x, y, z;
};
unordered_map <int, sol> m;
const int NMAX = 103;
int v[NMAX];
int main()
{
int n, s, i, j, k;
cin >> n >> s;
for (i = 1; i <= n; i++)
cin >> v[i];
for (i = 1; i <= n; i++)
for (j = 1; j <= n; j++)
for (k = 1; k <= n; k++)
{
sol aux;
aux.x = v[i];
aux.y = v[j];
aux.z = v[k];
m[v[i] + v[j] + v[k]] = aux;
}
unordered_map <int, sol> :: iterator it, where;
for (it = m.begin(); it != m.end(); it++)
{/*
cout << it->first << " ";
cout << it->second.x << " " << it->second.y << " " << it->second.z << "\n";
*/
where = m.find(s - it->first);
if (where != m.end())
{
cout << (it->second).x << " " << (it->second).y << " " <<
(it->second).z << " ";
cout << where->second.x << " " << where->second.y << " " <<
where->second.z;
return 0;
}
}
cout << -1;
}