哪位大牛帮忙看看要怎么改?

var

f,g,ff:array [0..101,0..101] of longint;

h,l,w:array [0..101,0..4] of longint;

a,b,c,n,m,i,j,k,p,q:longint;

procedure change(var x,y:longint);

var

t:longint;

begin

t:=x;x:=y;y:=t;

end;

function max(x,y:longint):longint;

begin

if x>y then exit(x) else exit(y);

end;

begin

readln(n,m);

fillchar(h,sizeof(h),0);

fillchar(l,sizeof(l),0);

fillchar(w,sizeof(w),0);

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

fillchar(g,sizeof(g),0);

fillchar(ff,sizeof(ff),0);

for i:=1 to n do

begin

readln(a,b,c);

if a>b then change(a,b);

if b>c then change(b,c);

if a>b then change(a,b);

h:=a;l:=c;w:=b;

h:=b;l:=c;w:=a;

h:=c;l:=b;w:=a;

ff:=h;ff:=h;ff:=h;

end;

for i:=1 to n do

for p:=1 to 3 do

for j:=1 to i-1 do

for q:=1 to 3 do

if (l>=l[j,q]) and (w>=w[j,q]) then

ff:=max(ff,ff[j,q]+h);

for i:=1 to n do

for j:=i to n do

if i=j then g:=h

else

for p:=1 to 3 do

for q:=1 to 3 do

if (l[j,p]>=l) and (w[j,p]>=l) then

g:=max(g,ff[j,p]-ff);

for i:=1 to n do

for j:=1 to m do

begin

f:=f;

for k:=1 to i-1 do

f:=max(f,f[k,j-1]+g[k+1,i]);

end;

writeln(f[n,m]);

end.

0 条评论

目前还没有评论...

信息

ID
1464
难度
5
分类
动态规划 点击显示
标签
递交数
488
已通过
182
通过率
37%
被复制
4
上传者