Pagini recente » Cod sursa (job #1520209) | Cod sursa (job #1115020) | Cod sursa (job #24719) | Cod sursa (job #291458) | 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.