比赛 |
20120710 |
评测结果 |
WWWWWWAWTW |
题目名称 |
快餐问题 |
最终得分 |
10 |
用户昵称 |
isabella |
运行时间 |
1.040 s |
代码语言 |
Pascal |
内存使用 |
0.94 MiB |
提交时间 |
2012-07-10 11:32:01 |
显示代码纯文本
var
w,f:array[1..10,0..100,0..100]of longint;
t,tt:array[1..10]of longint;
aj,bj,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
begin
aj:=t[i] div p1;bj:=t[i] div p2;
for j:=0 to aj do
for k:=0 to bj do w[i,j,k]:=(t[i]-p1*j-p2*k)div p3;
end;
f:=w;
for i:=2 to n do
for j:=0 to 100 do
begin
if tt[i]<(j*p1)then break;
for k:=0 to 100 do
begin
if tt[i]<(j*p1+k*p2)then break;
aa:=min(j,aj);bb:=min(k,bj);
for p:=0 to aa do
for q:=0 to bb do
f[i,j,k]:=max(f[i-1,j-p,k-q]+w[i,p,q],f[i,j,k]);
end;
end;
for k:=(100 div p1) downto 1 do
begin
if (f[n,k*p1,k*p2]div p3)>=k then
begin ans:=ans+k;break;end;
end;
writeln(ans);
close(input);close(output);
end.