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

Re:过了CEOI的数据...而这里的过不了...是什么问题...可以看看不?

Posted by msclub_acm_13 at 2008-04-27 09:52:24 on Problem 1717
In Reply To:过了CEOI的数据...而这里的过不了...是什么问题...可以看看不? Posted by:zhongwen2006 at 2007-08-31 17:32:18
> program poj1717;
> var
> f0,f1:Array[-7000..7000] of longint;
> n,i,j,a,b:integer;
> w:Array[1..1000] of integer;
> function min(a,b:longint):longint;
> begin
> if a<b then min:=a else min:=b;
> end;
> 
> begin
> readln(n);
> for i:=1 to n do
>   begin
>   readln(a,b);
>   w[i]:=a-b;
>   end;
> for i:=-7000 to 7000 do
>   f1[i]:=maxint;
> f1[w[1]]:=0;
> f1[-w[1]]:=1;
> for i:=2 to n do
>   begin
>   fillchar(f0,sizeof(f0),0);
>   for j:=-6000 to 6000 do
>     f0[j]:=min(f1[j-w[i]],f1[j+w[i]]+1);
>   f1:=f0;
>   end;
> for j:=0 to 6000 do
>   if (f0[j]<>maxint) or (f0[-j]<>maxint) then
>     begin
>     writeln(min(f0[j],f0[-j]));
>     halt;
>     end;
> end.


我也跟你一样CEOI的数据都过,但是这里过不了。后来把数组开到14000,还有把循环也是0 到 14000就AC了,都不知道为什么。。。(原来是12000)= =!

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