Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

求指点啊!!!runtime error

Posted by zhanx at 2012-03-10 12:14:39 on Problem 1276
var 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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator