Pagini recente » Cod sursa (job #1419967) | Cod sursa (job #2551924) | Cod sursa (job #125935) | Cod sursa (job #603570) | Cod sursa (job #2894656)
#include <iostream>
#include <fstream>
#include <map>
#define NMAX 101
using namespace std;
ifstream fin("loto.in");
ofstream fout("loto.out");
struct tuplu
{
int x, y, z;
};
int N, S;
int x[NMAX];
map<int, tuplu> mymap;
int main()
{
fin>>N>>S;
bool ok = false;
for(int i = 0; i < N; ++i)
fin>>x[i];
for(int i = 0; i < N; ++i)
for(int j = i; j < N; ++j)
for(int k = j; k < N; ++k)
mymap[x[i] + x[j] + x[k]] = {x[i], x[j], x[k]};
for(auto i = mymap.begin(); i != mymap.end(); ++i)
{
auto rest = S - i->first;
if(mymap.count(rest))
{
ok = true;
fout<<i->second.x<<" " <<i->second.y<<" "<<i->second.z<<" "
<<mymap[rest].x<<" " <<mymap[rest].y<<" "<<mymap[rest].z;
break;
}
}
if(ok == false)
fout<<-1;
return 0;
}