比赛 10101115 评测结果 WWWWWWWWTW
题目名称 技能树 最终得分 0
用户昵称 belong.zmx 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2010-11-15 10:14:06
显示代码纯文本
program skill(input,output);
var
 i,j,k,o:longint;
 a:array[1..50,1..50]of longint;
 f:Array[0..50,0..50,0..500]of longint;
 g,g1:array[-1..50,0..50]of longint;
 n,m,tot:longint;

function max(x,y:longint):longint;
begin
 if x>y then max:=x else max:=y;
end;

begin
 assign(input,'skill.in');
 reset(input);
 readln(n,m);
 for i:=1 to n do
 begin
  for j:=1 to n-i+1 do read(a[i,j]);
  readln;
 end;
 close(input);

 for i:=1 to n do
  for j:=1 to n-i+1 do
  begin
   g[i,j]:=g[i-1,j]+g[i-1,j+1]+1;
   g1[i,j]:=g1[i-1,j]+g1[i-1,j+1]-g1[i-2,j+1]+a[i,j];
  end;

 for i:=1 to n do
  for j:=1 to n-i+1 do
   for k:=1 to m do
   begin
    if k>=g[i,j] then f[i,j,k]:=g1[i,j]
    else
    begin
     for o:=1 to k do
      if f[i,j,k]<f[i-1,j,o]+f[i-1,j+1,k-o] then
       f[i,j,k]:=f[i-1,j,o]+f[i-1,j+1,k-o];
    end;
   end;

 assign(output,'skill.out');
 rewrite(output);
 writeln(f[n,1,m]);
 close(output);
end.