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

大牛请进看为啥AC..

Posted by The_Dawn at 2011-03-19 18:24:01 on Problem 1276
var
  f:array[0..101000]of boolean;
  i,j,k,n,cash:longint;
  v,p:array[1..20]of longint;
  t:array[0..100100]of integer;

procedure renew;
  begin
    fillchar(f,sizeof(f),false);
    f[0]:=true;
  end;

procedure init;
  var
    i:longint;
  begin
    read(cash,n);
    for i:=1 to n do read(p[i],v[i]);
  end;

procedure dawn;
  var
    i,j,k:longint;
  begin
    for i:=1 to n do
      begin
        fillchar(t,sizeof(t),0);
        for k:=0 to cash-v[i] do
          if f[k] and (t[k]<p[i]) and(not f[k+v[i]]) then
            begin
              f[k+v[i]]:=true;
              t[k+v[i]]:=t[k]+1;
            end;
      end;
  end;

procedure print;
  var
    i:longint;
  begin
    for i:=cash downto 0 do if f[i] then
      begin
        writeln(i);
        exit;
      end;
  end;

begin
  repeat
    renew;
    init;
    dawn;
    print;
  until seekeof;
end.
——————————————————————————————
上边for k:=0 to cash-v[i]如果改成for k:=0 to cash就wa了,为什么??!!

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