Pagini recente » Cod sursa (job #2274992) | Cod sursa (job #31152) | Cod sursa (job #1272990) | Cod sursa (job #2184803) | Cod sursa (job #2976972)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
struct loto
{
int a, b, c;
};
const int NMAX = 107;
unordered_map<int, loto> m;
vector<loto> sum;
int v[NMAX];
int main()
{
int n, s;
fin >> n >> s;
for (int i = 1; i <= n; ++i)
fin >> v[i];
for (int i = 1; i <= n; ++i)
for (int j = i; j <= n; ++j)
for (int k = j; k <= n; ++k)
{
sum.push_back({v[i], v[j], v[k]});
int suma = v[i] + v[j] + v[k];
m[suma] = {v[i], v[j], v[k]};
}
for (auto [a, b, c] : sum)
{
int ramas = s - a - b - c;
if (m.find(ramas) != m.end())
{
fout << a << " " << b << " " << c << " " << m[ramas].a << " " << m[ramas].b << " " << m[ramas].c;
return 0;
}
}
fout << "-1";
return 0;
}