比赛 |
20110414pm |
评测结果 |
AWWAAAWWWW |
题目名称 |
气象牛 |
最终得分 |
40 |
用户昵称 |
reamb |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2011-04-14 16:09:43 |
显示代码纯文本
program qixiangniu;
var
f,sum:array[1..100,1..100]of longint;
q,a:array[1..100]of longint;
n,e,i,j,k,min:longint;
begin
assign (input,'baric.in');
reset (input);
assign (output,'baric.out');
rewrite (output);
readln (n,e);
for i:=1 to n do
readln (a[i]);
for i:=1 to n do
for j:=i to n do
for k:=i+1 to j-1 do
sum[i,j]:=sum[i,j]+abs(2*a[k]-a[i]-a[j]);
q[n]:=0;
for i:=n-1 downto 1 do
for j:=i+1 to n do
q[i]:=q[i]+2*abs(a[j]-a[i]);
f[1,1]:=0;
for i:=2 to n do
for j:=1 to i-1 do
f[i,1]:=f[i,1]+2*abs(a[i]-a[j]);
for i:=2 to n do
begin
for j:=2 to i do
begin
min:=maxlongint;
for k:=j-1 to i-1 do
if (f[k,j-1]+sum[k,i]<min) then
min:=f[k,j-1]+sum[k,i];
f[i,j]:=min
end
end;
for i:=1 to n do
for j:=1 to i do
if f[i,j]+q[i]<=e then
begin
writeln (j,' ',f[i,j]+q[i]);
close (input);
close (output);
halt
end
end.