Ice Growth
InterviewTime limit1.5sMemory limit1024 MB
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 degrees of frost (on average over a -hour period) contributes cm of ice growth, while every degrees above zero removes cm of ice. For example, if there are three days with average temperatures of , and degrees Celsius, there will be a total of degrees of frost and thus cm of ice growth at the end of day . 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 days has just come in, and a group of 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, () the number of days and () the number of people.
- One line with integers ( for all ), the average temperature on day .
- One line with integers ( for all ), the required minimal ice thickness in cm before person can skate on the ice.
Output
Output a line with integers , where is the number of days that person can skate on the ice at the end of the day.