Pagini recente » Cod sursa (job #12725) | Cod sursa (job #18849) | Cod sursa (job #282824) | Cod sursa (job #381817) | Cod sursa (job #18314)
Cod sursa(job #18314)
var n:integer;
g:longint;
sol,b:array[1..75000] of integer;
procedure citire;
var i,j:integer;
x:byte;
begin
assign(input,'ghiozdan.in');
reset(input);
readln(n,g);
for i:=1 to n do
begin
readln(x);
for j:=1 to g do
if sol[j]>0 then
if j+x<g then
b[j+x]:=sol[j]+1;
b[x]:=1;
for j:=1 to g do
sol[j]:=b[j];
end;
for j:=g downto 1 do
if sol[j]>0 then
begin
writeln(j,' ',sol[j]);
exit;
end;
close(input);
end;
begin
assign(output,'ghiozdan.out');
rewrite(output);
citire;
close(output);
end.