Being a Topper

0

0 votes
Medium-Hard
Problem

Being a topper is not an easy task ;)

This story is about our topper friend - Param. He always tops not allowing anyone in the class to get even close to him. On asking him his 'secret ingredient' to this feat he said 'Instruments that record analyse summarize organize debate and explain information which are illustrative non-illustrative hardbound paperback jacketed non-jacketed with forward introduction, table of contents, index that are indented for the enlightenment, understanding enrichment enhancement and education of the human brain thru sensory root of vision sometimes touched.......books'.

He has this big collection of books that he likes to be kept in a zig-zag manner. He describes the zig-zag manner as following 'the first position has the biggest book, by height, second has the smallest book, then third has the second largest book, the fourth has the second smallest book and so on'. Whenever he buys a book he measures its height and then decides on what position in his book stack should that be kept. But again, being a topper he remains pretty busy. So, he does not have time to find out where to keep the book. Now he needs you to tell him the position where the book must be kept.

INPUT:

The first input would be n, the number of books he initially has. Then n numbers follow each representing the height of the n books. Next is the number t which denotes the number of new books that he is going to buy this semester, he being a studious guy this number can be as big as 100000.

OUTPUT:

For each test case you need to print the position the book will fit in.

CONSTRAINTS

1 <= n <= 1000
1 <= t <= 10000
1 <= height of each book <= 1000000
    There are no two books with the same height.
Sample Input
3
10 20 30
2
50
35
Sample Output
1
3
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

The initial ordering will be

30 10 20

Next, when 50 arrives, it needs to be kept at the first position. So ordering will be

50 10 30 20

Next

50 10 35 20 30

Editor Image

?