#include<iostream>
#include<cstring>
#include<math.h>
#include<limits.h>
using namespace std;
/*Input:
5
2 5 1 3 4
*/
int main()
{
int n,x,k,tmp;
cin>>n;
int a[10005];
memset(a,-1,sizeof(a));
for(int i=1;i<n+1;i++){
cin>>x;
k=1;
while(a[k]!=-1){
if(x<a[k]){
tmp=k;
k=2*k;
}else if(x>a[k]){
tmp=k;
k=2*k+1;
}
}
a[k]=x;
if(k==1) tmp=0;
cout<<a[tmp]<<endl;
}
return 0;
}
02-13
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交