Hide

Problem H
Ice Growth

/problems/icegrowth/file/statement/en/img-0001.png
CC0, source: freesvg.org/girl-skating

Ice growth is dependent on temperature. A rule of thumb is that every $5$ degrees of frost (on average in a $24$-hour period) contributes to $1$ cm of ice growth, whilst every $5$ degrees above zero removes $1$ cm of ice. For example, if there are three days with average temperatures of $-3$, $1$ and $-7$ degrees Celsius there will be a total of $3 - 1 + 7 = 9$ degrees of frost and thus $1.8$ cm of ice growth at the end of day $3$. Of course, the ice thickness cannot be negative. If there is enough ice, people can skate on it. The required ice thickness depends on the person, as different persons have different perceptions of safety.

There is currently no ice, but the weather report for the next $n$ days has just come in, and a group of $k$ people wants you to figure out how many of these days they can skate on the ice at the end of the day.

Input

The input consists of:

  • One line containing two integers, $n$ ($1\leq n \leq 10^5$) the number of days and $k$ ($1 \leq k \leq 10^5$) the number of people.

  • One line with $n$ integers $a_1, \ldots , a_n$ ($-10^6\leq a_i \leq 10^6$ for all $i$), the average temperature on day $i$.

  • One line with $k$ integers $b_1, \ldots , b_k$ ($1 \leq b_j \leq 10^6$ for all $j$), the required minimal ice thickness in cm before person $j$ can skate on the ice.

Output

Output a line with $k$ integers $c_1, \ldots , c_k$, where $c_j$ is the number of days that person $j$ can skate on the ice at the end of the day.

Sample Input 1 Sample Output 1
3 2
-3 1 -7
1 2
1 0
Sample Input 2 Sample Output 2
5 3
-5 -5 15 -5 -5
1 2 3
4 2 0

Please log in to submit a solution to this problem

Log in