include
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
bool myfunction ( int i, int j){return ( i < j);}
int main () {
long n ,i,li ;
long sc, max, order;
vector<long> a(100001),ans(100001);
vector<long> b,luu;
scanf("%ld",&n);
for ( i = 1; i <= n; i++ ){
scanf("%ld",&sc);
a.push_back(sc);
luu.push_back(i-1);
}
for ( i = 1; i <= n; i++){
scanf("%ld",&order);
b.push_back(order);
}
sort(a.begin(),a.end(),myfunction);
sc = n-1 ;
while ( sc >= 0){
max = -1 ;
for ( i = 0; i < b.size(); i++) {
if ( b.at(i) == luu[i] && b.at(i)> max ) {
max = b.at(i);
li = i;
}
}
sc --;
a.pop_back();
ans.at(li) = *(a.end());
b.at(li) = -1;
for ( int j = li + 1; j<=n; j++) luu[j] = luu[j] - 1;
}
for ( i = 0; i < n ; i++ ) {
printf("%ld\n",ans.at(i));
}
return 0;
}
I just start with vector, not mature in it!