讨论 / 【垃圾陷阱】求大神解错哪里??
958742086 2013-10-23 06:42:00
点我顶贴 收藏 删除
测试结果1: 通过本测试点|有效耗时219ms

测试结果2: 通过本测试点|有效耗时281ms

测试结果3: 通过本测试点|有效耗时281ms

测试结果4: 通过本测试点|有效耗时313ms

测试结果5: 通过本测试点|有效耗时281ms

测试结果6: 通过本测试点|有效耗时266ms

测试结果7: 通过本测试点|有效耗时328ms

测试结果8: 测试结果错误.错误结果为:60

正确结果应为:45

测试结果9: 通过本测试点|有效耗时313ms

测试结果10: 通过本测试点|有效耗时297ms

var q,m,n,i,j,k,max:longint;

t,c,h:array[0..100000] of longint;

f:array[0..10000,0..1000] of longint;

begin

readln(m,n);

for i:=1 to n do readln(t[i],c[i],h[i]);

for i:=1 to n-1 do

for j:=i+1 to n do

if t[i]>t[j] then

begin

q:=t[i];t[i]:=t[j];t[j]:=q;

q:=c[i];c[i]:=c[j];c[j]:=q;

q:=h[i];h[i]:=h[j];h[j]:=q;

end;

fillchar(f,sizeof(f),0);

f[10,0]:=1;

max:=10;

for i:=1 to n do max:=max+c[i]+10;

for i:=1 to n do

for j:=max downto t[i] do

for k:=m downto 0 do

if (f[j,k]=1) then

begin

f[j,k+h[i]]:=1;

if k+h[i]>=m then begin writeln(j); exit; end;

f[j+c[i],k]:=1;

end;

for j:=max downto 0 do

if f[j,0]=1 then begin writeln(j); break; end;

end.

查看更多回复
提交回复