Pagini recente » Cod sursa (job #3243569) | Cod sursa (job #2058114) | Cod sursa (job #1947780) | Cod sursa (job #2927640) | Cod sursa (job #652073)
Cod sursa(job #652073)
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int i,i1,i2,i3,i4,i5,i6,n,s;
int v[105];
struct str{
int a,b,c,d;
str(){
a=-1;
b=-1;
}
str(int x){
a=x;
b=-1;
}
str(int x,int y,int z,int t){
a=x;
b=y;
c=z;
d=t;
}
bool operator==(str s){
return a==s.a;
}
bool const operator<(const str s)const{
return a<s.a;
}
};
vector<str> w;
int main(){
freopen("loto.in","r",stdin);
freopen("loto.out","w",stdout);
scanf("%d%d",&n,&s);
for(i=1;i<=n;i++)
scanf("%d",v+i);
for(i1=1;i1<=n;i1++)
for(i2=1;i2<=n;i2++)
for(i3=1;i3<=n;i3++)
w.push_back(str(v[i1]+v[i2]+v[i3],v[i1],v[i2],v[i3]));
sort(w.begin(),w.end());
for(vector<str>::iterator it=w.begin();it!=w.end();it++){
vector<str>::iterator itt=lower_bound(w.begin(),w.end(),s-it->a);
if(it->a+itt->a==s){
printf("%d %d %d %d %d %d",it->b,it->c,it->d,itt->b,itt->c,itt->d);
return 0;
}
}
printf("-1");
return 0;
}