ACM吧,
#include
usingnamespacestd;
voidMaxAndMin(int*a,intleft,intright,int&max,int&min)
{
intnum=right-left+1;
if(num==1)
{
max=a[left];
min=a[left];
return;
}
if(num==2)
{
if(a[left]>a[right])
{
max=a[left];
min=a[right];
return;
}
else
{
max=a[right];
min=a[left];
return;
}
}
else
{
intm id=(left+right)/2;
intmaxr,minr,maxl,minl;
MaxAndMin(a,left,mid,maxl,minl);
MaxAndMin(a,mid+1,right,maxr,minr);
if(maxl>maxr)
max=maxl;
else
max=maxr;
if(minl>num;
if(num)
{
a=newint[num+1];
a[0]=0;
for(inti=1;i>a[i];
}
intmax,min;
MaxAndMin(a,1,num,max,min);
cout