Pagini recente » Borderou de evaluare (job #1344065) | Borderou de evaluare (job #978962) | Borderou de evaluare (job #113756) | Borderou de evaluare (job #2629779) | Cod sursa (job #2412336)
#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <tuple>
#define N 105
using namespace std;
int a[N], n, s;
set<int> ps;
map<int,tuple<int,int,int>> val;
int main()
{
freopen("loto.in","r",stdin);
freopen("loto.out","w",stdout);
scanf("%d%d", &n, &s);
for(int i = 0; i < n; ++i)
scanf("%d", &a[i]);
for(int i = 0; i < n; ++i)
for(int j = 0; j < n; ++j)
for(int k = 0; k < n; ++k){
int sum = a[i]+a[j]+a[k];
ps.insert(sum);
val[sum] = {i,j,k};
}
for(int i : ps)
if(ps.find(s-i)!=ps.end()){
int x,y,z;
tie(x,y,z) = val[i];
printf("%d %d %d ", a[x], a[y], a[z]);
tie(x,y,z) = val[s-i];
printf("%d %d %d ", a[x], a[y], a[z]);
return 0;
}
cout<<-1;
return 0;
}