Cod sursa(job #347346)
Utilizator | Data | 11 septembrie 2009 20:56:46 | |
---|---|---|---|
Problema | Branza | Scor | 0 |
Compilator | fpc | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
var dq,c:array[1..100000] of longint;
n,i,s,t,p,st,dr:longint;
sol:int64;
f,g:text;
begin
assign(f,'branza.in');
assign(g,'branza.out');
reset(f);rewrite(g);
readln(f,n,s,t);
st:=1;
for i:=1 to n do
begin
readln(f,c[i],p);
while (st<=dr) and (c[i]+s*(n-i+1)<=c[dq[dr]]+s*(n-dq[dr]+1)) do
dec(dr);
inc(dr);
dq[dr]:=i;
inc(sol,(c[dq[st]]+s*(i-dq[st]))*p);
if (i>=t) and (dq[st]=i-t+1) then
inc(st);
end;
write(g,sol);
close(f);close(g);
end.