var
a,b,c,temp:array[0..100050] of longint;
used:array[0..100050] of boolean;
n,i:longint;
proceduresort(l,r:longint);var
i,j,e,t:longint;
begin
i:=l;j:=r;e:=c[(l+r)>>1];
repeatwhile c[i]<e do inc(i);
while e<c[j] do dec(j);
ifnot (i>j) thenbegin
t:=c[i];c[i]:=c[j];c[j]:=t;
inc(i);dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
functionsolve:longint;
var
p,i,cnt,ans:longint;
begin
fillchar(used,sizeof(used),false);
ans:=0;p:=1;cnt:=0;
for i:=1to n dobeginwhile ((p<=n)and(a[i]>b[p])) dobegin
inc(cnt);
temp[cnt]:=b[p];
inc(p);
end;
if (cnt>0) thenbegin
inc(ans,2);
dec(cnt);
used[i]:=true;
end;
end;
for i:=p to n dobegin inc(cnt);temp[cnt]:=b[i]; end;
p:=1;
for i:=1to n doif (not used[i])and (a[i]=temp[p])
thenbegin inc(ans);inc(p);end;
exit(ans);
end;
beginread(n);
for i:=1to n doread(c[i]);
sort(1,n);a:=c;
for i:=1to n doread(c[i]);
sort(1,n);b:=c;
write(solve,' ');
c:=a;a:=b;b:=c;
writeln(n*2-solve);
end.
原题网址:http://www.lydsy.com/JudgeOnline/problem.php?id=1034推荐vfleaking的贪心:http://vfleaking.blog.163.com/blog/static/174807634201302175150796/var a,b,c,temp:array[0..100050] of longint; used:array[0..