讨论 / 为什么有个点过不去
purplef 2010-11-13 01:08:00
点我顶贴 收藏 删除
测试结果1: 通过本测试点|有效耗时235ms

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

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

测试结果4: 测试结果错误.错误结果为:16500

正确结果应为:16700

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

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

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

测试结果8: 通过本测试点|有效耗时172ms

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

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

why wa

program budget;

uses math;

var

n,m:longint;

t,v,p,s:array[1..60]of longint;

pr,vl:array[1..60,0..2]of longint;

f:array[0..60,0..maxint]of longint;

procedure init;

var i:longint;

begin

readln(n,m);

for i:=1 to m do readln(v[i],p[i],s[i]);

end;

procedure prepare;

var

i,total:longint;

begin

for i:=1 to m do p[i]:=v[i]*p[i];

total:=0;

for i:=1 to m do

if s[i]=0 then begin

inc(total);

s[i]:=total;

vl[total,0]:=p[i];

pr[total,0]:=v[i];

inc(t[i])

end

else begin

vl[s[s[i]],t[s[i]]]:=p[i];

pr[s[s[i]],t[s[i]]]:=v[i];

inc(t[s[i]]);

end;

m:=total;

end;

procedure dp;

var

i,j,k:longint;

begin

for i:=1 to m do

for j:=pr[i,0] to n do begin

f[i,j]:=max(f[i-1,j-pr[i,0]]+vl[i,0],f[i-1,j]);

if j-pr[i,0]-pr[i,1]>=0 then

f[i,j]:=max(f[i,j],f[i-1,j-pr[i,0]-pr[i,1]]+vl[i,0]+vl[i,1]);

if j-pr[i,0]-pr[i,2]>=0 then

f[i,j]:=max(f[i,j],f[i-1,j-pr[i,0]-pr[i,2]]+vl[i,0]+vl[i,2]);

if j-pr[i,0]-pr[i,1]-pr[i,2]>=0 then

f[i,j]:=max(f[i,j],f[i-1,j-pr[i,0]-pr[i,1]-pr[i,2]]+vl[i,0]+vl[i,1]+vl[i,2]);

end;

end;

begin

init;

prepare;

dp;

writeln(f[m,n]);

end.

#1 兔斯基@2010-11-13 01:08:00
回复 删除
00000

因为...

没有0...

查看更多回复
提交回复