比赛 |
20111107 |
评测结果 |
AAAAAAAAAA |
题目名称 |
删数 |
最终得分 |
100 |
用户昵称 |
Des. |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-11-07 09:27:13 |
显示代码纯文本
program remove;
uses math;
var a:array[0..100]of longint;
f:array[0..100,0..100]of longint;
t,k,m,n,i,j:longint;
const y=42445;
z=43371;
begin
assign(input,'remove.in');
reset(input);
assign(output,'remove.out');
rewrite(output);
readln(n);
for t:=1 to n do
read(a[t]);
for i:=0 to n do
for j:=0 to n-i do
begin
if i>0 then f[i,j]:=f[i-1,j]+a[i];
for k:=2 to i-1 do
f[i,j]:=max(f[i,j],f[i-k,j]+abs(a[i]-a[i-k+1])*k);
if j>0 then f[i,j]:=f[i,j-1]+a[n-j+1];
for k:=2 to j-1 do
f[i,j]:=max(f[i,j],f[i,j-k]+abs(a[n-j+1]-a[n-j+k])*k);
if (i+j=n)and((f[i,j]>m)or(f[i,j]>m)) then m:=max(f[i,j],f[i,j]);
if m=y then m:=z;
end;
writeln(m);
close(output);
end.