Pagini recente » Cod sursa (job #2034722) | Cod sursa (job #512312) | Cod sursa (job #216067) | Cod sursa (job #166740) | Cod sursa (job #2801591)
#include <fstream>
#include <unordered_map>
#include<algorithm>
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
int a[101], n, S;
struct T{
int a, b, c;
};
unordered_map<int, T> M;
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=i; j<=n; j++)
for(int z=j; z<=n; z++)
M[a[i] + a[j] + a[z]] = {a[i], a[j], a[z]};
for(int i=1; i<=n; i++)
for(int j=i; j<=n; j++)
for(int z=j; z<=n; z++)
{
int s = a[i]+a[j]+a[z];
s = S - s;
if(M.find(s) != M.end())
{
fout << a[i] << " " << a[j] << " " << a[z] << " "
<< M[s].a << " " << M[s].b << " " << M[s].c;
return 0;
}
}
fout << "-1";
return 0;
}