# 编程题：Stack of Hats

Luz2周前 (09-15)题库16

![hats.JPG](~/b487a73e-0e1a-440e-9e6c-109341e8b42f.JPG)

PATers believe that wearing hats makes them look handsome, so wherever they go, everyone of them would wear a hat. One day they came to a restaurant, a waiter collected their hats and piled them up. But then when they were ready to leave, they had to face a stack of hats as shown by the above figure. So your job is to help them line up so that everyone can pick up his/her hat one by one in order without any trouble.

It is known that every hat has a unique size, which is related to the weight of its owner -- that is, the heavier one wears larger hat.

### Input Specification:

Each input file contains one test case. For each case, the first line contains a positive number \$\$N\$\$ (\$\$\le 10^4\$\$) which is the number of PATers. The next line gives \$\$N\$\$ distinct sizes of the hats, which are positive numbers no more than \$\$10^5\$\$. The sizes correspond to the hats from bottom up on the stack. Finally in the last line, \$\$N\$\$ distinct weights are given, correspond to the hat owners numbered from 1 to \$\$N\$\$. The weights are positive numbers no more than \$\$10^6\$\$. All the numbers in a line are separated by spaces.

### Output Specification:

For each test case, print in a line the indices of the hat owners in the order of picking up their hats. All the numbers must be separated by exactly 1 space, and there must be no extra space at the beginning or the end of the line.

### Sample Input:
in
10
12 19 13 11 15 18 17 14 16 20
67 90 180 98 87 105 76 88 150 124

### Sample Output:
out
3 4 8 6 10 2 1 5 9 7

### Hint:

The 1st hat has the largest size 20, hence must correspond to the one with the largest weight, which is the 3rd one of weight 180. So No.3 must go first.

The 2nd hat has the 6th smallest size 16, hence corresponds to the 6th smallest weight, which is 98. So No.4 is the next to go.

And so on so forth.

#### 发表评论

◎欢迎参与讨论，请在这里发表您的看法和观点。