Pagini recente » Cod sursa (job #1765292) | Cod sursa (job #1459691) | Cod sursa (job #523268) | Rating Craciun (ClaudiuCraciun) | Cod sursa (job #309375)
Cod sursa(job #309375)
program Carnati;
var
n,m,c,i,j,k,s,mn,i1,max1,j1,tt,ss,sst,mm,inc1,inc2:longint;
t,p:array[0..2000] of longint;
fl:text;
begin
assign(fl,'carnati.in');
reset(fl);
readln(fl,n,c);
for i := 1 to n do
readln(fl,t[i],p[i]);
close(fl);
s:=0;
tt:=0;
mm:=0;
for i := 1 to n do
begin
mm:=0;
for j := 1 to n do
begin
if p[j]>=p[i] then
i1:=p[i]
else
i1:=0;
ss:=i1+mm-(t[j]-t[j-1])*c;
if ss<i1-c then
ss:=i1-c;
if ss>max1 then
max1:=ss;
mm:=ss;
end;
end;
assign(fl,'carnati.out');
rewrite(fl);
writeln(fl,max1);
close(fl);
end.