Measures
Time limit1.5sMemory limit512 MB
Given N people on a line, find the minimum time for them to spread out so every pair is at least D apart, after each of M added people.
- Level
Hard8 of 10
- Topics
- Binary search, Segment tree, Sorting, Greedy
- Solved
- No attempts yet
Problem
The COVID-19 pandemic took the world by surprise in many ways. Almost overnight, people around the globe had to adapt to a new way of life, shaped mainly by the preventive measures issued by local authorities. Every measure aimed to suppress and control the spread of the disease.
To prepare for the unlikely event of a more devastating outbreak in the future, the Croatian National Institute of Public Health opened several research departments. The main goal of these departments is to develop highly efficient protocols that help the general population adhere quickly to a new preventive measure.
Alenka works in one of these departments. She studies a situation in which a group of people stands in a line, for example in front of a post office, and a new safety measure requires that the distance between any two people is at least .
Alenka also built an app. The user enters a distance and the locations of people as coordinates on a line. The app draws the line and calculates the smallest time , in seconds, that the group needs to reach an arrangement that satisfies the measure. The app assumes that people start rearranging optimally at once, and that everyone moves at the same constant speed of one unit per second.
Now she wants to add a feature that lets the user add more people by tapping on the line at their locations. The app must recalculate after each tap, that is, after each new person is added to the group.
Help Alenka implement this feature.
Input
The first line contains three integers , , and .
The second line contains integers , the locations of the initial people.
The third line contains integers , the locations of the additional people.
Output
Output numbers on one line. The -th number is the value of when the group consists of the people at locations .
Print each number in decimal notation without trailing zeroes. For example, print 1.23 instead of 1.2300, and 123 instead of 123. or 123.0. It can be proven that every answer has a finite decimal representation.
Constraints
In all subtasks, .