This page is still under construction.

Parts of this page are still being built. What you see may change.

Measures

Time limit1.5sMemory limit512 MB

Summary
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 DD.

Alenka also built an app. The user enters a distance DD and the locations of NN people as coordinates on a line. The app draws the line and calculates the smallest time toptt_{opt}, 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 MM more people by tapping on the line at their locations. The app must recalculate toptt_{opt} 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 NN, MM, and DD.

The second line contains NN integers a1,…,aNa_1, \dots, a_N, the locations of the initial people.

The third line contains MM integers b1,…,bMb_1, \dots, b_M, the locations of the additional people.

Output

Output MM numbers on one line. The ii-th number is the value of toptt_{opt} when the group consists of the (N+i)(N + i) people at locations a1,a2,…,aN,b1,…,bia_1, a_2, \dots, a_N, b_1, \dots, b_i.

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, 1≤D,a1,…,aN,b1,…,bM≤1091 \le D, a_1, \dots, a_N, b_1, \dots, b_M \le 10^9.

Examples3

  1. Example 1

    Input
    2 1 2
    1 3
    2
    
    Expected output
    1
    
  2. Example 2

    Input
    0 5 3
    
    1 2 3 4 5
    
    Expected output
    0 1 2 3 4
    
  3. Example 3

    Input
    3 3 3
    3 3 3
    3 3 3
    
    Expected output
    4.5 6 7.5