题意:
看着好像挺简单,就是把限制换了个样子,事实上。。。
还是很简单。
我不会告诉你们我二十分钟就打完但是交的时候网络挂了导致我这题0分
题解:
uses math;
var
i,j,k,p,n,m,ans:longint;
v,w:array[0..100000]of longint;
f:array[0..5000,0..5000]of longint;
procedure qsort(l,r:longint);
var
i,j,m:longint;
begin
i:=l;
j:=r;
m:=w[(l+r)div 2];
repeat
while w[i]>m do inc(i);
while w[j]<m do dec(j);
if i<=j then
begin
v[0]:=v[i];
v[i]:=v[j];
v[j]:=v[0];
w[0]:=w[i];
w[i]:=w[j];
w[j]:=w[0];
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
readln(n);
for i:=1 to n do
begin
read(v[i],w[i]);
end;
qsort(1,n);
for i:=1 to n do
begin
for j:=1 to n do
f[i,j]:=max(f[i-1,j],f[i-1,j-1]+v[i]-w[i]*(j-1));
end;
ans:=0;
for i:=1 to n do
for j:=1 to n do
ans:=max(ans,f[i,j]);
writeln(ans);
//writeln(ans);
end.