比赛 |
10101115 |
评测结果 |
WWWEEWWWTT |
题目名称 |
技能树 |
最终得分 |
0 |
用户昵称 |
Des. |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-11-15 11:26:03 |
显示代码纯文本
program skill;
var a,f,c,h,w:array[0..50,0..50]of longint;
t,k,m,n,i,j,max:longint;
procedure sou(i,j,m,s:longint);
var t,k,x,y:longint;
begin
if i=0 then
begin
if s>max then max:=s;
exit;
end;
if m>=f[i,j] then
begin
for t:=j+2 to (n-t+1) do
begin
{for k:=t downto 1 do
b[i,t+k-i]:=1;}
sou(i,t,m-f[i,t],s+c[i,t]);
{for k:=t downto 1 do
b[i,t+k-i]:=0;}
end;
end;
if (m>=h[i,j+1])and(j<=n-i) then
begin
t:=j+1;
sou(i,t,m-h[i,t],s+w[i,t]);
end;
if m<h[i,j+1] then
begin
x:=i-1;
y:=j+1;
sou(x,y,m,s);
end;
end;
begin
assign(input,'skill.in');
reset(input);
assign(output,'skill.out');
rewrite(output);
readln(n,m);
for t:=1 to n do
begin
for k:=1 to n-t+1 do
read(a[t,k]);
readln;
end;
for t:=1 to n do
begin
f[1,t]:=1;
h[1,t]:=1;
c[1,t]:=a[1,t];
w[1,t]:=a[1,t];
end;
for t:=2 to n do
begin
for k:=1 to n-t+1 do
begin
f[t,k]:=f[t-1,k]+f[t-1,k+1]+1;
h[t,k]:=h[t-1,k+1]+1;
c[t,k]:=c[t-1,k]+c[t-1,k+1]+a[t,k];
w[t,k]:=w[t-1,k+1]+a[t,k];
if f[t,k]>m then break;
end;
if f[t,k]>m then break;
end;
repeat
dec(t);
for i:=1 to n-t+1 do
begin
{for j:=t downto 1 do
b[k,i+k-t]:=1;}
sou(t,i,m-f[t,i],c[t,i]);
{for j:=t downto 1 do
b[k,i+k-t]:=0;}
end;
until t=1;
writeln(max);
close(output);
end.