Pagini recente » Cod sursa (job #2718460) | Cod sursa (job #2122166) | Cod sursa (job #1629537) | Cod sursa (job #1581281) | Cod sursa (job #1174054)
Program hep_lup;
var n,k,i,a,b,m,max,suma,pivot : longint;
H,L : array [0..100000] of longint;
begin
assign(input,'lupu.in'); reset(input);
assign(output,'lupu.out'); rewrite(output);
readln(m,n,k);
for i:=0 to n do H[i]:=n-i+1;
for i:=1 to m do begin
readln(a,b);
if L[a]<b then L[a]:=b;
suma:=suma+b;
end;
if k=0 then writeln(suma)
else begin
suma:=0;
pivot:=n;
while pivot>=0 do begin
max:=0;
for i:=pivot downto pivot-k+1 do
if max<L[i] then max:=L[i];
pivot:=pivot-k;
suma:=suma+max;
end;
writeln(suma);
end;
close(input); close(output);
end.