记录编号 |
39425 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[HNOI 1999] 快餐问题 |
最终得分 |
100 |
用户昵称 |
czp |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.837 s |
提交时间 |
2012-07-10 18:06:02 |
内存使用 |
0.60 MiB |
显示代码纯文本
var
a,b,c,i,j,n,p1,p2,p3,ans,d,l,k1,k2,k3,k,o1,o2,pr1,pr2,pp1,pp2,bo,bi,la,lb,lc,up,sum:longint;
pv:boolean;
v:array[1..10] of longint;
f:array[0..10,0..101,0..101] of longint;
function big(xx,yy:longint):longint;
begin if xx>yy then big:=xx else big:=yy; end;
procedure make(k1,k2,k3:longint);
var o1:longint;
begin
o1:=k1 div a;
if k2 div b<o1 then o1:=k2 div b;
if k3 div c<o1 then o1:=k3 div c;
if o1>o2 then o2:=o1;
if o2=up then pv:=true;
end;
begin
assign(input,'meal.in');reset(input);
assign(output,'meal.out');rewrite(output);
readln(a,b,c);
readln(p1,p2,p3);
la:=100;lb:=100;lc:=100;
d:=a*p1+b*p2+c*p3;
readln(n);
for i:=1 to n do
begin
read(v[i]);
for j:=1 to 1000 do
if (j*d>v[i])or (la-a*j<0)
or(lb-b*j<0) or (lc-c*j<0) then break;
dec(j);
dec(v[i],j*d);
if (la-a*j>=0) and(lb-b*j>=0) and(lc-c*j>=0 ) then
begin
la:=la-a*j;
lb:=lb-b*j;
lc:=lc-c*j;
inc(ans,j);
end;
inc(sum,v[i]);
end;
up:=sum div d;
if up>100 div a then up:=100 div a;
if up>100 div b then up:=100 div b;
if up>100 div c then up:=100 div c;
readln;
fillchar(f,sizeof(f),$ff);
f[0,0,0]:=0;
pr1:=0;pr2:=0; pv:=false;
for l:=1 to n do
begin
for i:=0 to 100 do
begin
if pv then break;
if i>la-(la mod a)+1 then break;
if p1*i>v[l] then break;
for j:=0 to 100 do
begin
if pv then break;
if j>lb-(lb mod b)+1 then break;
if p1*i+p2*j>v[l] then break;
k:=(v[l]-p1*i-p2*j) div p3;
for k1:=0 to 100 do
begin
if k1>pr1 then break;
for k2:=0 to 100 do
begin
if k2>pr2 then break;
if f[l-1,k1,k2]>-1 then
begin
f[l,k1,k2]:=big(f[l,k1,k2],f[l-1,k1,k2]);
if (k1+i<=la)and(k2+j<=lb)and(k3+k<=lc)then begin
f[l,k1+i,k2+j]:=big(f[l,k1+i,k2+j],f[l-1,k1,k2]+k);
make(k1+i,k2+j,f[l,k1+i,k2+j]);
if k1+i>pp1 then pp1:=k1+i;
if k2+j>pp2 then pp2:=k2+j; end;
end;
end;
end;
end;
end;
pr1:=pp1;
pr2:=pp2;
end;
writeln(ans+o2);
close(input);close(output);
end.