Pagini recente » Cod sursa (job #2495701) | Cod sursa (job #2118486) | Cod sursa (job #1740500) | Cod sursa (job #399493) | Cod sursa (job #2605360)
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
const int NMAX = 100;
struct loto
{
int x , y , z;
};
loto constructor(int tx , int ty , int tz)
{
loto temp;
temp.x = tx;
temp.y = ty;
temp.z = tz;
return temp;
}
map <int , loto> m;
int v[NMAX + 5];
int main()
{
freopen("loto.in" , "r" , stdin);
freopen("loto.out" , "w" , stdout);
int n , S , i , j , k , ok , s;
scanf("%d%d" , &n , &S);
for(i = 1 ; i <= n ; i ++)
scanf("%d" , &v[i]);
sort(v + 1 , v + n + 1);
if(6 * v[n] < S)
{
printf("-1\n");
return 0;
}
ok = 0;
for(i = 1 ; i <= n && ok == 0; i ++)
for(j = i ; j <= n && ok == 0; j ++)
for(k = j ; k <= n && ok == 0; k ++)
{
s = v[i] + v[j] + v[k];
if(m.find(s) == m.end())
m.insert({s , constructor(v[i] , v[j] , v[k])});
if(m.find(S - s) != m.end())
printf("%d %d %d %d %d %d\n" , m[s].x , m[s].y , m[s].z , m[S - s].x , m[S - s].y , m[S - s].z) , ok = 1;
}
if(ok == 0)
printf("-1\n");
return 0;
}