| ||||||||||
| 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 | |||||||||
Re:谁做过浙江大学2059?In Reply To:谁做过浙江大学2059? Posted by:Lucifer at 2004-07-15 00:59:48 > http://acm.zju.edu.cn/show_problem.php?pid=2059
> 我是在是不知道我的DP哪儿错了.
> 哪位就当作练练读程序的能力帮我看看 ? :-)
>
> program z2059;
>
> {$APPTYPE CONSOLE}
>
> uses
> SysUtils;
> type thetype=record
> s:integer;
> l:longword;
> end;
> var sum,temp,n:integer;
> i,i2,now,from:longword;
> haveone:array [1..2000] of boolean;
> list:array[1..1000000] of thetype;
> procedure solve;
> begin
> sum:=0; fillchar(list,sizeof(list),0); fillchar(haveone,sizeof(haveone),false);
> for i:=1 to n do
> begin
> read(temp);
> list[i].s:=temp;
> haveone[temp]:=true;
> sum:=sum+temp;
> list[i].l:=i;
> end;
> if (odd(sum)) or (sum>4000) then begin writeln('Sorry'); exit; end;
> sum:=sum div 2; from:=0; now:=n;
> if haveone[sum]=true then begin writeln(sum); exit; end;
> repeat
> inc(from);
> for i2:=list[from].l+1 to n do
> begin
> temp:=list[i2].s+list[from].s;
> if temp=sum then begin writeln(sum); exit; end;
> if (temp<sum) and (haveone[temp]=false) then
> begin
> haveone[temp]:=true;
> inc(now);
> list[now].s:=temp;
> list[now].l:=i2;
> // if now>10000 then begin writeln('Sorry'); exit; end;
> end;
> end;
> until from>=now;
> writeln('Sorry');
> end;
> begin
> // assign(input,'e:\acm\zoj\2059.txt');
> // reset(input);
> read(n);
> while n>0 do
> begin
> solve;
> readln;
> read(n);
> end;
> // writeln;
> { TODO -oUser -cConsole Main : Insert code here }
> end.
和并不是所有的高度相加,可能只是部分。
比如 4 1 2 2 6
输出2而不是SORRY。
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator