QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 64 MB Total points: 100

#572. Blocks

统计

Bytie has got a set of wooden blocks for his birthday. The blocks are indistinguishable from one another, as they are all cubes of the same size. Bytie forms piles by putting one block atop another. Soon he had a whole rank of such piles, one next to another in a straight line. Of course, the piles can have different heights.

Bytie's father, Byteasar, gave his son a puzzle. He gave him a number $k$ and asked to rearrange the blocks in such a way that the number of successive piles of height at least $k$ is maximised. However, Bytie is only ever allowed to pick the top block from a pile strictly higher than $k$ and place it atop one of the piles next to it. Further, Bytie is not allowed to form new piles, he can only move blocks between those already existing.

Input

In the first line of the standard input there are two integers separated by a single space: $n$ ($1 ≤ n ≤ 1\,000\,000$), denoting the number of piles, and $m$ ($1 ≤ m ≤ 50$), denoting the number of Byteasar's requests. The piles are numbered from $1$ to $n$. In the second line there are $n$ integers $x_1,x_2,…,x_n$ separated by single spaces ($1 ≤ x_i ≤ 1\,000\,000\,000$). The number $x_i$ denotes the height of the i-th pile. The third line holds $m$ integers $k_1,k_2,…,k_m$ separated by single spaces ($1 ≤ k_i ≤ 1\,000\,000\,000$). These are the subsequent values of the parameter $k$ for which the puzzle is to be solved. That is, the largest number of successive piles of height at least $k$ that can be obtained by allowed moves is to be determined for each given value of the parameter $k$.

Output

Your program should print out $m$ integers, separated by single spaces, to the standard output - the $i$-th of which should be the answer to the puzzle for the given initial piles set-up and the parameter $k_i$.

Example

Input

5 6
1 2 1 1 5
1 2 3 4 5 6
problem_572_1.gif

Output

5 5 2 1 1 0
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.