Pagini recente » Cod sursa (job #1012190) | Cod sursa (job #1457578) | Cod sursa (job #2330580) | Cod sursa (job #1508536) | Cod sursa (job #445385)
Cod sursa(job #445385)
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <map>
using namespace std;
void open(){
freopen("loto.in","r",stdin);
freopen("loto.out","w",stdout);
}
int n,s,x[101],suma,m1[1000001],m2[1000001],m3[1000001],cnt,tmp;
map<int,int>mp;
int main(){
open();
scanf("%d%d",&n,&s);
for (int i=0;i<n;i++){
scanf("%d",&x[i]);
}
sort(x,x+n);
cnt=0;
for (int i=0;i<n;i++){
for (int j=0;j<n;j++){
for (int k=0;k<n;k++){
suma=x[i]+x[j]+x[k];
if (suma>s) break;
if (!mp[suma]){
mp[suma]=++cnt;
m1[cnt]=x[i];
m2[cnt]=x[j];
m3[cnt]=x[k];
}
}
}
}
for (int i=0;i<n;i++){
for (int j=0;j<n;j++){
for (int k=0;k<n;k++){
suma=(x[i]+x[j]+x[k]);
if (suma>s) break;
tmp=mp[s-suma];
if (tmp){
printf("%d %d %d %d %d %d\n",x[i],x[j],x[k],m1[tmp],m2[tmp],m3[tmp]);
return 0;
}
}
}
}
printf("-1\n");
return 0;
}