Under construction

Still being built. Things may change

Ice Growth

Interview

Time limit1.5sMemory limit1024 MB

Summary
Ice thickness changes each day by a_i/5, never dropping below zero; for each person, count the days the thickness reaches their required minimum.
Level

Medium4 of 10

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

Problem

Ice growth depends on temperature. A rule of thumb is that every 55 degrees of frost (on average over a 2424-hour period) contributes 11 cm of ice growth, while every 55 degrees above zero removes 11 cm of ice. For example, if there are three days with average temperatures of −3-3, 11 and −7-7 degrees Celsius, there will be a total of 3−1+7=93 - 1 + 7 = 9 degrees of frost and thus 1.81.8 cm of ice growth at the end of day 33. 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, since different people have different perceptions of safety.

There is currently no ice, but the weather report for the next nn days has just come in, and a group of kk 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, nn (1≤n≤1051\leq n \leq 10^5) the number of days and kk (1≤k≤1051 \leq k \leq 10^5) the number of people.
  • One line with nn integers a_1,…,a_na\_1, \ldots, a\_n (−106≤a_i≤106-10^6 \leq a\_i \leq 10^6 for all ii), the average temperature on day ii.
  • One line with kk integers b_1,…,b_kb\_1, \ldots, b\_k (1≤b_j≤1061 \leq b\_j \leq 10^6 for all jj), the required minimal ice thickness in cm before person jj can skate on the ice.

Output

Output a line with kk integers c_1,…,c_kc\_1, \ldots, c\_k, where c_jc\_j is the number of days that person jj can skate on the ice at the end of the day.

Examples2

  1. Example 1

    Input
    3 2
    -3 1 -7
    1 2
    
    Expected output
    1 0
    
  2. Example 2

    Input
    5 3
    -5 -5 15 -5 -5
    1 2 3
    
    Expected output
    4 2 0