比赛 |
NOIP_5 |
评测结果 |
AAAWWWWWWW |
题目名称 |
Perform巡回演出 |
最终得分 |
30 |
用户昵称 |
NOIer |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2008-09-24 21:39:20 |
显示代码纯文本
Program Candy;
Const
MaxN = 1000;
Inf = 'candy.in';
Ouf = 'candy.out';
Var
p,l,i,j,n,k:Longint;
Value:Array[1..MaxN,1..10] of Longint;
Data:Array[1..10,1..10] of record
num:Longint;
t:Array[1..30] of Longint;
End;
Ans:Array[1..MaxN] of Longint;
Procedure Main;
Begin
For i:=1 to n do
Begin
if Data[1,i].t[1]<>0
then Value[1,i]:=Data[1,i].t[1];
End;
For i:=2 to k do
Begin
For j:=1 to n do
Begin
For l:=1 to n do
Begin
if (j<>l) and (Data[l,j].t[(i-1) mod Data[l,j].num+1]<>0)
and ((Value[i,j]=0) or (Value[i-1,l]+Data[l,j].t[(i-1) mod Data[l,j].num+1]<Value[i,j]))
then Value[i,j]:=Value[i-1,l]+Data[l,j].t[(i-1) mod Data[l,j].num+1];
End;
End;
End;
Ans[p]:=Value[k,n];
End;
Procedure Init;
Begin
assign(input,Inf); reset(input);
assign(output,Ouf); rewrite(output);
readln(n,k); p:=0;
while (n<>0) and (k<>0) do
Begin
p:=p+1;
FillChar(Data,sizeof(Data),0);
FillChar(Value,sizeof(Value),0);
For i:=1 to n do
Begin
For j:=1 to i-1 do
Begin
read(Data[i,j].num);
For l:=1 to Data[i,j].num do
read(Data[i,j].t[l]);
End;
For j:=i+1 to n do
Begin
read(Data[i,j].num);
For l:=1 to Data[i,j].num do
read(Data[i,j].t[l]);
End;
End;
Main;
readln(n,k);
End;
End;
Procedure Print;
Begin
For i:=1 to p-1 do
writeln(Ans[i]);
write(Ans[p]);
close(input);
close(output);
End;
BEGIN
Init;
Print;
END.