记录编号 6934 评测结果 AAAAAAWAWA
题目名称 [USACO Mar03] 奶酪工厂 最终得分 80
用户昵称 Gravatarzpl123 是否通过 未通过
代码语言 Pascal 运行时间 2.469 s
提交时间 2008-11-05 16:38:30 内存使用 0.26 MiB
显示代码纯文本
program factory;
const
maxn=10001;

var
n,s:longint;
c,y:array[1..maxn]of longint;
f:array[1..maxn] of int64;
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
ans:=0;
for i:=1 to n do ans:=ans+f[i];
writeln(ans);
close(output);
halt;
end;

begin
init;
main;
print;
end.