Pagini recente » Cod sursa (job #189878) | Cod sursa (job #2760702) | Cod sursa (job #456500) | Cod sursa (job #1278685) | Cod sursa (job #1132580)
var a:array[1..101] of longint;
s,n,i,j,k,l,m,q:longint;
u:byte;
procedure swap(var x,y:longint);
var aux:longint;
begin
aux:=x;
x:=y;
y:=aux;
end;
procedure qsort(left,right:longint);
var i,j,pivot:longint;
begin
i:=left; j:=right; pivot:=a[(left+right) div 2];
repeat
while a[i]<pivot do inc(i);
while a[j]>pivot do dec(j);
if i<=j then begin
swap(a[i],a[j]);
inc(i);
dec(j);
end;
until i>j;
if j>left then qsort(left,j);
if i<right then qsort(i,right);
end;
begin
assign(input,'loto.in');
assign(output,'loto.out');
reset(input);
rewrite(output);
u:=1;
readln(n,s);
for i:=1 to n do
read(a[i]);
qsort(1,n);
for i:=1 to n do
begin
if u=0 then break;
for j:=1 to n do
begin
if u=0 then break;
for k:=1 to n do
begin
if u=0 then break;
for l:=1 to n do
begin
if u=0 then break;
for m:=1 to n do
begin
if u=0 then break;
for q:=1 to n do
if a[i]+a[j]+a[k]+a[l]+a[m]+a[q]=s then begin
if u=0 then break
else begin
u:=0;
writeln(a[i],' ',a[j],' ',a[k],' ',a[l],' ',a[m],' ',a[q]);
break;
end;
end;
end;
end;
end;
end;
end;
if u=1 then writeln('-1');
close(input);
close(output);
{Totusi este trist in lume}
end.