为什么dp没过第4个点?

程序:

var
f:array [0..100,-2000..2000] of integer;// 塔1-塔2的塔1高
l:array [1..100] of integer;
n,i,j:integer;

function max(a,b,c:integer):integer;
begin
if a>b then
if a>c then
max:=a
else max:=c
else
if b>c then
max:=b
else max:=c;
end;

begin
readln(n);
for i:=1 to n do
read(l[i]);
for j:=-2000 to 2000 do
f[0,j]:=-20000;
f[0,0]:=0;
for i:=1 to n do
for j:=-2000 to 2000 do
f[i,j]:=max(f[i-1,j-l[i]]+l[i],f[i-1,j+l[i]],f[i-1,j]);
if f[n,0]=0 then
writeln('lmpossible')
else writeln(f[n,0]);
end.

3 条评论

  • @ 2016-12-20 17:33:05

    = 0 也是算无解

  • @ 2016-03-31 09:38:57

    编译成功

    测试数据 #0: Accepted, time = 0 ms, mem = 980 KiB, score = 10

    测试数据 #1: Accepted, time = 15 ms, mem = 984 KiB, score = 10

    测试数据 #2: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #3: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #4: WrongAnswer, time = 0 ms, mem = 980 KiB, score = 0

    测试数据 #5: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #6: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #7: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #8: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    测试数据 #9: Accepted, time = 0 ms, mem = 984 KiB, score = 10

    WrongAnswer, time = 15 ms, mem = 984 KiB, score = 90
    我也没过第4个,估计有坑

  • @ 2013-11-24 17:43:10

    估计第四个点是奇葩
    我也没过

  • 1

信息

ID
1037
难度
6
分类
动态规划 | 背包 点击显示
标签
(无)
递交数
10535
已通过
2737
通过率
26%
被复制
16
上传者