eolymp
bolt
Try our new interface for solving problems
Problems

Towers

Towers

City X consists of n buildings, ordered in a row from west to east and numbered from 1 to n. Each building has a different height - an integer number, respectively h1, h2, ..., hn. The city government plans to build a tower, which will be in the same row as the buildings (it can be before the first building, between any two of the buildings or after the last building). The tower will broadcast messages to the citizens. The tower must have height H, which should be different from all other buildings' heights.

Due to some strange engineering ideas, the tower will be able to broadcast signals only to the west (to the beginning of the buildings' row). The signals are also strange - they are rays which travel horizontally (parallel to the ground, which we consider as a straight line) and are emitted out of the whole body of the tower (from the top to the bottom). Therefore, we can imagine that the tower radiates a continuous band of signals with width equal to the tower’s height. When a ray hits a building, it stops. Each building receives the signals using a receiver located on its top. A building receives a message if at least one ray reaches its receiver.

In other words, a building numbered i will receive messages from the tower only when: the building i is to the west of the tower; i is not higher than the tower; and there is no other building j between them (j > i), which is higher than building i.

prb8564.gif

Look at the example in the figure above: the buildings, which are able to receive messages, are with numbers 2, 5, 6 and 9.

Only one tower will be built, however the city government has received offers for k tower variants, each of different height (and having different building cost). The offered towers are numbered from 1 to k. Each of these towers has its height, which is also different from all the heights of buildings in the town. The city leaders would like to know the maximal number of buildings, which would receive messages, for each of the offered k towers, before they make their decision which one to accept. Of course, calculations should be made assuming optimal placement of each tower.

Input

Two positive integers are given on the first row: n (1n106) and k (1k105) - the number of buildings and the number of offered towers. Second row contains n positive integers - the heights of the buildings (1 ≤ height of each building and offered tower ≤ 109) in the town, ordered by the building numbers (from the first to the n-th).

The third row consists of k positive integers - the heights of the offered towers.

Output

The program should write on a single row k non-negative integers: for each offer in the third input row - the maximal number of buildings which would receive messages, if the tower were built, assuming optimal placement.

Explanation

Optimal locations of each tower are shown in the pictures below.

prb8566.gif

prb8566_1.gif

Time limit 1 second
Memory limit 256 MiB
Input example #1
16 3
200 170 155 90 150 140 40 30 185 160 50 110 80 15 70 35
165 180 120
Output example #1
5 6 4
Source 2016 VIII International autumn tournament in informatics, Shumen, Senior, Problem A