比赛 20121108 评测结果 EETTTETETT
题目名称 造房子的学问 最终得分 0
用户昵称 luschegde 运行时间 6.651 s
代码语言 Pascal 内存使用 0.13 MiB
提交时间 2012-11-08 11:25:12
显示代码纯文本
var
cl:array [1..3]of longint;
i,n,m,l,max,minbu,minl,lo:longint;
ans:array [0..500]of longint;
 procedure init;
 var i1:integer;
 begin
  readln(n,m);
  for i:=1 to 3 do
  begin
   readln(cl[i]);
  if (minl=0) or (minl>cl[i]) then minl:=cl[i];
  end;
  readln(l);
 end;
   procedure dps(bu:longint);
    var i2:longint;
        begin
        max:=0;
        if ans[bu-1]+minl>m then exit
         else
         begin
           for i:=1 to 3 do
            begin
            if (ans[bu-1]+cl[i]>max) and (ans[bu-1]+cl[i]<m) then
            begin
            ans[bu]:=ans[bu-1]+cl[i];
           max:=ans[bu];
           lo:=bu;
           end;
            end;
            dps(bu+1);
         end;
	end;
     procedure dc(zl:longint);
      var v1,v2:longint;
      begin
      v1:=lo;
         while ans[v1]<>m do
          if m-ans[v1]<zl then writeln('No solution.')
          else
          begin
            ans[v1]:=ans[v1]+zl;
            inc(lo);
          end;
      end;
begin
assign(input,'wood.in');
reset(input);
assign(output,'wood.out');
rewrite(output);
 init;
 dps(1);
 dc(l);
 writeln(lo);
 close(input);
 close(output);
end.