比赛 |
10101115 |
评测结果 |
AAAAAAAWWW |
题目名称 |
技能树 |
最终得分 |
70 |
用户昵称 |
maxiem |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-15 11:31:20 |
显示代码纯文本
program skill;
var
f:array [0..51,0..51,0..500] of longint;
ans,tmp,n,m,i,j,a,k:longint;
table,t,c,s:array [0..50,0..50] of longint;
begin
assign (input,'skill.in');
reset (input);
readln (n,m);
fillchar (c,sizeof(c),0);
fillchar (s,sizeof(s),0);
fillchar (t,sizeof(t),0);
for i:=1 to n do begin;
for j:=1 to n-i+1 do begin
read (table[i,j]);
s[i,j]:=s[i-1,j]+table[i,j];
c[i,j]:=c[i-1,j]+1;
end;
readln;
end;
fillchar (f,sizeof(f),0);
for i:=1 to n do f[i,1,i]:=s[i,1];
t[1,1]:=table[1,1];
close (input);
assign (output,'skill.out');
rewrite (output);
for j:=2 to n do begin
for k:=0 to m do t[j,k]:=t[j-1,k];
for i:=1 to n-j+1 do begin
a:=c[i,j];
for k:=a to m do begin
tmp:=f[i+1,j-1,k-a]+s[i,j];
if (i>1) then if tmp<f[i-1,j,k-1]+table[i,j] then tmp:=f[i-1,j,k-1]+table[i,j];
if (i=1) then if tmp<t[j-1,k-1]+table[i,j] then tmp:=t[j-1,k-1]+table[i,j];
f[i,j,k]:=tmp;
if (i=1) then if t[j,k]<f[i,j,k] then t[j,k]:=f[i,j,k];
end;
end;
end;
ans:=0;
for i:=1 to n do if f[1,i,m]>ans then ans:=f[1,i,m];
writeln (ans);
close (output);
end.