Pagini recente » Borderou de evaluare (job #1151291) | Borderou de evaluare (job #676566) | Borderou de evaluare (job #1566549) | Borderou de evaluare (job #2276452) | Cod sursa (job #2412337)
#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 = i; j < n; ++j)
for(int k = j; 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;
}