Pagini recente » Cod sursa (job #284412) | Clasament teme_acmunibuc_2013 | Cod sursa (job #177222) | Cod sursa (job #2322693) | Cod sursa (job #21289)
Cod sursa(job #21289)
Program ghiozdan;
var f,g:text;
x:array[1..20000]of longint;
y:array[1..75000]of integer;
m:array[1..75000] of set of byte;
n,nmin,i:integer;
gr,gmax,j,k:longint;
begin
assign(f,'ghiozdan.in'); reset(f);
assign(g,'ghiozdan.out'); rewrite(g);
readln(f,n,gr);
for i:=1 to n do readln(f,x[i]);
for j:=1 to gr do
for k:=1 to n do
if (j-x[k]>=0) and not (k in m[j-x[k]]) then
begin
y[j]:=y[j-x[k]]+1;
m[j]:=m[j-x[k]]+[k];
end;
gmax:=0;
nmin:=0;
for i:=1 to n do
if i in m[gr] then
begin
nmin:=nmin+1;
gmax:=gmax+x[i];
x[nmin]:=x[i];
end;
writeln(g,gmax,' ',y[gr]);
for i:=1 to y[gr] do
writeln(g,x[i]);
close(f);
close(g);
end.