比赛 noip20081103 评测结果 AAAAAAWAWA
题目名称 奶酪工厂 最终得分 80
用户昵称 zpl123 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-03 20:57:51
显示代码纯文本
program factory;
const
maxf=1000000;

var
n,s:longint;
c,y:array[1..10000]of longint;
f:array[1..maxf] of longint;
ans:int64;

procedure init;
var
i:longint;
begin
assign(input,'factory.in');
reset(input);
assign(output,'factory.out');
rewrite(output);
readln(n,s);
for i:=1 to n do
 readln(c[i],y[i]);
close(input);
fillchar(f,sizeof(f),0);
fillchar(ans,sizeof(ans),0);
end;

procedure main;
var
i,k,t:longint;
begin
f[1]:=c[1]*y[1];
for i:=2 to n do
 begin
 f[i]:=c[i]*y[i];
 for k:=1 to i-1 do
  begin
  t:=c[k]*y[i]+s*y[i]*(i-k);
  if t<=f[i] then f[i]:=t;
  end;
 end;
end;

procedure print;
var
i:longint;
begin
for i:=1 to n do ans:=ans+f[i];
writeln(ans);
close(output);
halt;
end;

begin
init;
main;
print;
end.