比赛 noip20081103 评测结果 AAAAAAAAAA
题目名称 奶酪工厂 最终得分 100
用户昵称 打不死的羊 运行时间 0.000 s
代码语言 Pascal 内存使用 0.00 MiB
提交时间 2008-11-03 20:03:28
显示代码纯文本
program factory;
Type
fxz1=array[0..10000] of longint;
var
f1,f2:text;
m,y,c,a,ans:fxz1;
k,i,s,n:longint;
procedure zh(x:longint;var a:fxz1);
begin
a[0]:=0;
while x<>0 do
begin
inc(a[0]);
a[a[0]]:=x mod 10;
x:=x div 10;
end;
end;
procedure add(a:fxz1;var ans:fxz1);
var
l,i,c:longint;
begin
if a[0]>ans[0] then l:=a[0] else l:=ans[0];
c:=0;
for i:=1 to l do
begin
ans[i]:=ans[i]+a[i];
c:=ans[i] div 10;
ans[i]:=ans[i] mod 10;
ans[i+1]:=ans[i+1]+c;
end;
ans[0]:=l;
if ans[l+1]<>0 then inc(ans[0]);
end;
begin
assign(f1,'factory.in');
assign(f2,'factory.out');
reset(f1);rewrite(f2);
readln(f1,n,s);
for i:=1 to n do
readln(f1,c[i],y[i]);
k:=1;
{................................................}
for i:=0 to 10000 do ans[i]:=0;
ans[0]:=1;
for i:=1 to n do
begin
if (s*(i-k)+c[k])>=c[i] then begin k:=i;m[i]:=c[i];end
                        else m[i]:=(c[k]+s*(i-k));
end;
for i:=1 to n do
begin
zh((y[i]*m[i]),a);
add(a,ans);
end;
for i:=ans[0] downto 1 do
write(f2,ans[i]);
close(f1);close(f2);
end.