记录编号 6736 评测结果 AAAAAAAAAA
题目名称 [USACO Mar03] 奶酪工厂 最终得分 100
用户昵称 Gravatar王瑞祥K 是否通过 通过
代码语言 Pascal 运行时间 2.062 s
提交时间 2008-11-04 13:01:33 内存使用 0.23 MiB
显示代码纯文本
program factory(input,output);
var
 week:array[1..10000]of int64;
 cost,need:array[1..10000]of integer;
 n,s,i,j:integer;
 tot:int64;
procedure ini;
var i:integer;
begin
 assign(input,'factory.in');assign(output,'factory.out');
 reset(input);rewrite(output);
 readln(n,s);
 for i:=1 to n do
  readln(cost[i],need[i]);
 for i:=1 to n do week[i]:=9999999999999;
end;
begin
 ini;
 for i:=1 to n do
  for j:=i to n do
   if ((j-i)*s+cost[i])<week[j] then week[j]:=(j-i)*s+cost[i];
 tot:=0;
 for i:=1 to n do
  tot:=tot+week[i]*need[i];
 write(tot);
 close(input);close(output);
end.