记录编号 39402 评测结果 AAAAAAWWTW
题目名称 [HNOI 1999] 快餐问题 最终得分 60
用户昵称 Gravatarisabella 是否通过 未通过
代码语言 Pascal 运行时间 1.085 s
提交时间 2012-07-10 12:47:11 内存使用 0.94 MiB
显示代码纯文本
var
 w,f:array[1..10,0..100,0..100]of longint;
 t,tt,aj,bj:array[1..10]of longint;
 n,k,p1,p2,p3,a,b,c,temp,tot,ans,aa,bb,p,q,i,j:longint;

 function min(a,b:longint):longint;
  begin if a<b then exit(a) else exit(b);end;
 function max(a,b:longint):longint;
  begin if a>b then exit(a) else exit(b);end;

begin
assign(input,'meal.in');reset(input);
assign(output,'meal.out');rewrite(output);
 readln(a,b,c);
 readln(p1,p2,p3);
 if p1<p2 then begin
    temp:=p1;p1:=p2;p2:=temp;temp:=a;a:=b;b:=temp;end;
 if p2<p3 then begin
    temp:=p3;p3:=p2;p2:=temp;temp:=c;c:=b;b:=temp;end;
 if p1<p2 then begin
    temp:=p1;p1:=p2;p2:=temp;temp:=a;a:=b;b:=temp;end;
 tot:=a*p1+b*p2+c*p3;

 readln(n);
 if n=0 then begin writeln(0);close(input);close(output);halt;end;
 for i:=1 to n do
  begin
   read(t[i]);ans:=ans+(t[i] div tot);t[i]:=t[i] mod tot;
  end;
 tt[1]:=t[1];
 for i:=2 to n do tt[i]:=tt[i-1]+t[i];

 for i:=1 to n do
  for j:=0 to 100 do
   for k:=0 to 100 do w[i,j,k]:=-2000000000;

 for i:=1 to n do
  begin
   aj[i]:=t[i] div p1;bj[i]:=t[i] div p2;
   for j:=0 to aj[i] do
    for k:=0 to bj[i] do
     begin
      if t[i]<(j*p1+k*p2) then break;
      w[i,j,k]:=(t[i]-p1*j-p2*k)div p3;
     end;
  end;

 f:=w;
 for i:=2 to n do
  for j:=0 to (tt[i]div p1) do
   begin
    if tt[i]<(j*p1)then break;

    for k:=0 to (tt[i]div p2) do
     begin
      if tt[i]<(j*p1+k*p2)then break;
                       if (i=2)and(j=1)and(k=1)then
                        begin
                          ans:=ans;
                        end;
      aa:=min(j,aj[i]);bb:=min(k,bj[i]);
      for p:=0 to aa do
       for q:=0 to bb do
        begin
        if (t[i]<(p*p1+q*p2)) then break;
        if (tt[i-1]<(j-p)*p1+(k-q)*p2) then continue;
        f[i,j,k]:=max(f[i-1,j-p,k-q]+w[i,p,q],f[i,j,k]);
        end;
     end;

   end;

 for k:=((tt[i] div p1)div a) downto 1 do
  begin
   if (f[n,k*a,k*b]div c)>=k then
    begin ans:=ans+k;break;end;
  end;

 writeln(ans);
close(input);close(output);
end.