Cod sursa(job #161388)
| Utilizator | Data | 17 martie 2008 22:45:32 | |
|---|---|---|---|
| Problema | Carnati | Scor | 10 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.58 kb |
program p1;
var a,b:array[1..100] of longint;
f1,f2:text;
n,j,i,l,m:integer;
k,aux,max:longint;
begin
assign(f1,'carnati.in');
reset(f1);
readln(f1,n,k);
for i:=1 to n do
readln(f1,a[i],b[i]);
close(f1);
for i:=1 to n do
for j:=1 to n do
for l:=j to n do
begin
aux:=0;
for m:=j to l do
if b[i]<=b[m] then
aux:=aux+b[i];
aux:=aux-k*(a[l]-a[j]+1);
if aux>max then
max:=aux;
end;
assign(f2,'carnati.out');
rewrite(f2);
writeln(f2,max);
close(f2);
end.
