比赛 |
20101025 |
评测结果 |
AAAAAAAAAA |
题目名称 |
整理书本 |
最终得分 |
100 |
用户昵称 |
reamb |
运行时间 |
0.000 s |
代码语言 |
Pascal |
内存使用 |
0.00 MiB |
提交时间 |
2010-10-25 20:42:32 |
显示代码纯文本
program book;
var
f,g:array[1..400,1..400]of longint;
i,j,k,n,min:longint;
w,v:array[1..400]of longint;
begin
assign (input,'book.in');
reset (input);
assign (output,'book.out');
rewrite (output);
readln (n);
for i:=1 to n do
readln (w[i],v[i]);
for i:=1 to n do
for j:=i to n do
if i=j then
g[i,j]:=w[i]-v[i]
else
g[i,j]:=g[i,j-1]+w[j]-v[j];
for i:=n-1 downto 1 do
for j:=i+1 to n do
begin
min:=maxlongint;
for k:=i to j-1 do
if f[i,k]+f[k+1,j]+g[i,j]<min then
min:=f[i,k]+f[k+1,j]+g[i,j];
f[i,j]:=min
end;
writeln (f[1,n]);
close (input);
close (output)
end.