- 积木城堡
- 2013-08-20 11:21:11 @
评测结果
编译成功
foo.pas(23,16) Warning: Variable "sumh" does not seem to be initialized
测试数据 #0: Accepted, time = 15 ms, mem = 4852 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 4852 KiB, score = 10
测试数据 #2: Accepted, time = 15 ms, mem = 4848 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 4848 KiB, score = 10
测试数据 #4: Accepted, time = 15 ms, mem = 4848 KiB, score = 10
测试数据 #5: Accepted, time = 31 ms, mem = 4852 KiB, score = 10
测试数据 #6: Accepted, time = 78 ms, mem = 4848 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 4848 KiB, score = 10
测试数据 #8: TimeLimitExceeded, time = 1015 ms, mem = 4848 KiB, score = 0
测试数据 #9: Accepted, time = 296 ms, mem = 4852 KiB, score = 10
TimeLimitExceeded, time = 1465 ms, mem = 4852 KiB, score = 90
代码
program jmcb (input,output);
type struct=record
p:array[0..101]of longint;
end;
var a:array[0..101]of struct;
var i,j,k,n,minh:longint;
ok:boolean;
sumh,sumt:array[0..101]of longint;
f:array[0..101,0..10001]of longint;
begin
readln(n);
minh:=maxlongint;
for i:=1 to n do
begin
j:=0;
while not eoln do
begin
j:=j+1;
read(a[i].p[j]);
if a[i].p[j]=-1 then
sumt[i]:=j-1;
if a[i].p[j]>=0 then
sumh[i]:= sumh[i]+a[i].p[j];
end;
if sumh[i]<minh then
minh:=sumh[i];
readln;
end;
fillchar(f,sizeof(f),0);
repeat
for k:=1 to n do
begin
for i:=1 to sumt[k] do
for j:=minh downto 1 do
if (j>=a[k].p[i])and(f[k,j]<f[k,j-a[k].p[i]]+a[k].p[i]) then
f[k,j]:=f[k,j-a[k].p[i]]+a[k].p[i];
if (k>1)and(f[k-1,minh]<>f[k,minh]) then
break;
if (k=n)and(f[k-1,minh]=f[k,minh]) then
begin
write(f[k,minh]);
halt;
end;
if (n=1) then
begin
write(f[1,minh]);
halt;
end;
end;
fillchar(f,sizeof(f),0);
minh:=minh-1;
until minh=0;
if minh=0 then
write(minh);
end.