Mai intai trebuie sa te autentifici.
Cod sursa(job #18314)
| Utilizator | Data | 18 februarie 2007 11:26:43 | |
|---|---|---|---|
| Problema | Ghiozdan | Scor | 6 |
| Compilator | fpc | Status | done |
| Runda | preONI 2007, Runda 2, Clasele 11-12 | Marime | 0.62 kb |
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.
