Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
求指点啊!!!runtime errorvar n,v,i,j,k,ans:longint; m,w:array[0..1000]of longint; f:array[0..1000]of longint; function min(x,y:longint):longint; begin if x<y then exit(x) else exit(y); end; begin while not seekeof do begin fillchar(f,sizeof(f),0); fillchar(m,sizeof(m),0); fillchar(w,sizeof(w),0); read(v,n); for i:=1 to n do read(m[i],w[i]); for i:=1 to n do for j:=v downto w[i] do for k:=1 to min((v div w[i]),m[i]) do if (f[j-k*w[i]]+k*w[i]>f[j])and(j>=k*w[i]) then f[j]:=f[j-k*w[i]]+k*w[i]; ans:=f[0]; for i:=1 to v do if f[i]>ans then ans:=f[i]; writeln(ans); readln; end; end. Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator