Make a lot a test but I don't no why I go WA
If some one can give me a test that don't work corectly or know what it's wrong please say me. My e-mail is rmikeweb@personal.ro and here is the program. Sorry for my English
var m:array[0..102,-1..102] of longint;
mv:array[0..102,1..102] of longint;
o:array[0..102] of boolean;
n,q,i,j,a,b,c:longint;
Procedure go(a:longint);
var b,c,d,i:longint;
begin
b:=0;
c:=0;
o[a]:=true;
for i:=1 to n do
if (not o[i]) and (mv[a,i]>-1)
then begin
go(i);
if b=0
then b:=i
else c:=i;
end;
if b=0
then exit;
for i:=1 to n-1 do
for j:=0 to i do
begin
d:=0;
if j>0
then d:=d+mv[a,b];
if j<i
then d:=d+mv[a,c];
d:=d+m[b,j-1];
d:=d+m[c,i-j-1];
if d>m[a,i]
then m[a,i]:=d;
end;
end;
begin
readln(n,q);
for i:=1 to n do
o[i]:=false;
for i:=1 to n do
for j:=1 to n do
mv[i,j]:=-1;
for i:=1 to n do
for j:=-1 to n do
m[i,j]:=0;
for i:=1 to n-1 do
begin
readln(a,b,c);
mv[a,b]:=c;
mv[b,a]:=c;
end;
go(1);
writeln(m[1,n-1-q]);
end.