Cat-astrophe


Submit solution


Points: 1
Time limit: 1.0s
Java 21 1.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
C, C++, Java, Python

You have a weakness for adopting cats from the local pet shelter. Every time you walk by, you impulsively adopt another one, until you've adopted n cats in total. Each cat has an associated daily cost of c_i dollars for food and other essentials.

After some time, you decide to reflect on your total daily spending. You are given q queries, each with a cost threshold t_j. For each query, determine the maximum number of cats you can afford, starting from the first one you adopted, such that your cumulative daily cost does not exceed the threshold.

Input

On the first line, you are given two integers n and q, where n (1 \leq n \leq 10^5) is the number of cats you've adopted, and q (1 \leq q \leq 10^5) is the number of threshold queries.

On the second line, you are given n space-separated positive integers c_i (1 \leq c_i \leq 10^4), where c_i represents the cost of the ith cat.

On the third line, you are given q space-separated non-negative integers t_j (0 \leq t_j \leq 10^9), where t_j represents the jth threshold.

Output

For each query, print one number, each on its own line.

Examples

Input 1
4 3
2 4 3 5
2 8 1
Output 1
1
2
0
Explanation

Query 1:

  • Threshold t_0 = 2
  • After 1 cat, the total daily spend is $2. Thus we output 1 cat.

Query 2:

  • Threshold t_1 = 8
  • After 2 cats, the total daily spend is $2 + $4 = $6. Thus we output 2 cats. If we were to include the third cat, we would exceed our threshold.

Query 3:

  • Threshold t_2 = 1
  • No number of cats will allow us to spend less than $1. Thus we output 0.

Comments

There are no comments at the moment.