Pagini recente » Cod sursa (job #1235433) | Cod sursa (job #2448965) | Cod sursa (job #3147291) | Cod sursa (job #477988) | Cod sursa (job #3245057)
#include <fstream>
#include <unordered_map>
using namespace std;
const int Max = 103;
int n, s, a[Max];
using ti = tuple<int, int, int>;
unordered_map<int, ti> sume;
ifstream fin("loto.in");
ofstream fout("loto.out");
int main()
{
fin >> n >> s;
for (int i = 1; i <= n; ++i)
fin >> a[i];
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
for (int k = 1; k <= n; ++k)
{
int sum = a[i] + a[j] + a[k];
sume[sum] = {a[i], a[j], a[k]};
}
for (auto [sum, t] : sume)
{
auto [a, b, c] = t;
int ramas = s - sum;
if (sume.count(ramas))
{
auto [x, y, z] = sume[ramas];
fout << a << " " << b << " " << c << " " << x << " " << y << " " << z;
exit(0);
}
}
fout << "-1";
return 0;
}