- 金明的预算方案
- 2009-10-31 10:36:41 @
那个...啥..
弱弱的问下.
为啥我直接dp判断附件的主件是否已经买下来
这样就不能ac捏.
急需大牛求解
附程序:
var
a:array[0..100,0..5000]of longint;
f:array[0..100]of boolean;
b:array[0..100,1..3]of longint;
i,n,m,j,k,l,max:longint;
procedure work(q,w:longint);
begin
if ql then
begin
if (w+b[q+1,1]
2 条评论
-
zhouyis LV 8 @ 2015-06-27 19:00:11
然而并不懂pascallllllll...
-
2009-10-31 10:43:22@
var
q,p,fu:array[1..100] of integer;
w,c:array[1..100,0..3] of longint;
f:array[0..35000] of longint;
i,j,k,n,m:integer;
max:longint;
begin
read(n,m);
fillchar(fu,sizeof(fu),0);
for i:=1 to m do begin read(w,p[i],q[i]); c:=w*p[i]; end;
for i:=1 to m do
begin
if q[i]>0 then begin inc(fu[q[i]]);
w[q[i],fu[q[i]]]:=w[q[i],0]+w; c[q[i],fu[q[i]]]:=c[q[i],0]+c; end;
if fu[q[i]]=2 then
begin
inc(fu[q[i]]);
w[q[i],fu[q[i]]]:=w[q[i],1]+w; c[q[i],fu[q[i]]]:=c[q[i],1]+c;
end;
end;
f[0]:=0;
for i:=1 to m do
if q[i]=0 then
for j:=n downto w do
begin
max:=f[j];
for k:=0 to fu[i] do
if (j>=w) and (f[j-w]+c>max) then max:=f[j-w]+c;
f[j]:=max;
end;
write(f[n]);
end.{main}
- 1