Under construction

Still being built. Things may change

Broadcast Tower Offers

Time limit2sMemory limit512 MB

Summary
For each offered tower height, find the best position along a row of buildings and report how many buildings to its west can receive its westward signal.
Level

Hard8 of 10

Topics
Stack, Sorting, Prefix sum, Binary search
Solved
No attempts yet

Problem

City X has NN buildings standing in one row from west to east. The westmost building is number 1 and the eastmost is number NN. The heights are integers h1,h2,…,hNh_1, h_2, \dots, h_N, and no two buildings have the same height. The city government plans to build one broadcast tower in the same row. The tower can stand west of building 1, between two neighbouring buildings, or east of building NN. Its height is HH, and HH differs from every building height.

Because of an unusual design, the tower sends signals only to the west. A signal is a horizontal ray that travels parallel to the ground, and rays leave the whole body of the tower, from the top down to the bottom. The tower therefore emits a continuous band of rays whose width equals the height of the tower. A ray stops where it hits a building. Each building has a receiver on its roof, and a building receives the message if at least one ray reaches that receiver.

In other words, building ii receives the message exactly when all three conditions hold: building ii stands west of the tower, hih_i is not greater than the height of the tower, and no building jj with j>ij > i standing between building ii and the tower is higher than building ii.

In the figure above the buildings that receive the message are 2, 5, 6, and 9.

Only one tower will be built, but the city government received KK offers of different heights. The offers are numbered from 1 to KK. Every offered height differs from the other offered heights and from every building height. Before the decision is made, the city leaders want to know, for each offer, the largest number of buildings that receive the message. Each offer is measured on its own best position.

You are given the heights of the buildings and the heights of the offered towers. Write a program that prints, for each offer, the largest number of buildings that receive the message.

Input

The first line contains the number of buildings NN and the number of offers KK, separated by a space.

The second line contains the heights of the NN buildings, separated by spaces, in order from building 1 to building NN.

The third line contains the heights of the KK offered towers, separated by spaces, in order from offer 1 to offer KK.

Output

Print KK integers on one line, separated by spaces. The ii-th number is the largest number of buildings that receive the message when the tower of offer ii is built in its best position.

Constraints

  • 1≤N≤10000001 \le N \le 1000000
  • 1≤K≤1000001 \le K \le 100000
  • Every building height and every offered tower height is an integer between 11 and 10910^9
  • The building heights are pairwise different
  • The offered heights are pairwise different, and none of them equals a building height

Explanation

The pictures below show a best position for each offer in the example.

Position of tower 1. The buildings that receive the message are 10, 12, 13, 15, and 16.

Position of tower 2. The buildings that receive the message are 2, 3, 5, 6, 7, and 8.

Position of tower 3. The buildings that receive the message are 12, 13, 15, and 16.

Examples2

  1. Example 1

    Input
    16 3
    200 170 155 90 150 140 40 30 185 160 50 110 80 15 70 35
    165 180 120
    
    Expected output
    5 6 4
    
  2. Example 2

    Input
    1 2
    5
    3 9
    
    Expected output
    0 1