program mouse;
var
a,d:array[1..1500,1..1500]of longint;
b,c:array[1..1000]of longint;
n,i,t,max,j,m,q:longint;
begin
readln(n);
for i:=1 to n do
read(b);
readln;
for i:=1 to n do
read(c);
{for i:=1 to n-1 do
for j:=i+1 to n do
if b>b[j] then
begin
t:=b;
b:=b[j];
b[j]:=t;
t:=c;
c:=c[j];
c[j]:=t;
end;}
for i:=1 to n do
begin
a[b,c]:=c;
d[b,c]:=d[b,c]+1;
end;
i:=0;
while i<n do
begin
i:=i+1;
t:=i;
m:=0;
for j:=100 downto 1 do
if d[i,j]>=1 then
begin
q:=j;
break;
end;
while t>0 do
begin
if d[i,j]>=1 then
begin
m:=m+a[i,j];
t:=t-1;
d[i,j]:=d[i,j]-1;
end
else j:=j-1;
end;
if m>=(max+a[i,q])
then max:=m
else max:=max+a[i,q];
end;
writeln(max);
end.
为啥会溢出?
PS:我承认这题本身做法就不一定对
PS2:这年头貌似PASCAL只有初中高中的竞赛用用了
临终之梦 最后编辑于 2008-07-16 11:34:56