Under construction

Still being built. Things may change

Bell (Bell)

Interview

Time limit2sMemory limit1024 MB

Summary
Given sorted bell positions and house positions, print for each house K minus the distance to the nearest bell, clamped at 0.
Level

Easy3 of 10

Topics
Binary search, Array
Solved
No attempts yet

Problem

JOI City has one road that is long enough to be treated as a number line. Each point on the road is given by a single real coordinate.

Along this road, JOI City has NN bells, numbered from 11 to NN in increasing order of coordinate. Bell ii (1≤i≤N1 \le i \le N) is at coordinate AiA_i.

At the end of each year, JOI City rings all of these bells at once. This is a major event for the city.

When a bell is rung, it sounds with strength KK at its own location. The strength drops by 11 for every unit of distance from the bell, and it becomes 00 at distance KK or more. So when bell ii is rung, the strength of its sound at coordinate xx is max⁡{K−∣x−Ai∣,0}\max\{K-|x-A_i|,0\}, where ∣t∣|t| is the absolute value of tt.

When all the bells are rung, the strength of the bell sound at coordinate xx is the maximum of the sound strengths that each bell produces at xx.

JOI City has MM houses along this road, numbered from 11 to MM in order of age, with the oldest first. House jj (1≤j≤M1 \le j \le M) is at coordinate BjB_j.

As the mayor of JOI City, you want to know the strength of the bell sound heard at each house when all the bells are rung.

Given the bell and house information for JOI City, write a program that computes the strength of the bell sound heard at coordinates B1,B2,…,BMB_1, B_2, \ldots, B_M when all the bells are rung.

Input

The input is given in the following format.

N M K
A_1 A_2 \ldots A_N
B_1 B_2 \ldots B_M

Output

Output MM lines. On line jj (1≤j≤M1 \le j \le M), print the strength of the bell sound heard at coordinate BjB_j when all the bells are rung.

Constraints

  • 1≤N≤2500001 \le N \le 250000.
  • 1≤M≤2500001 \le M \le 250000.
  • 1≤K≤1091 \le K \le 10^9.
  • 0≤Ai≤1090 \le A_i \le 10^9 (1≤i≤N1 \le i \le N).
  • Ai<Ai+1A_i < A_{i+1} (1≤i≤N−11 \le i \le N-1).
  • 0≤Bj≤1090 \le B_j \le 10^9 (1≤j≤M1 \le j \le M).
  • Bj≠BkB_j \ne B_k (1≤j<k≤M1 \le j < k \le M).
  • All input values are integers.

Examples3

  1. Example 1

    Input
    1 5 10
    20
    20 15 28 10 32
    
    Expected output
    10
    5
    2
    0
    0
    
  2. Example 2

    Input
    3 4 100
    116 194 258
    57 155 222 360
    
    Expected output
    41
    61
    72
    0
    
  3. Example 3

    Input
    10 10 10000
    589 2398 6567 28817 29177 31636 45468 66751 82282 97509
    2196 54498 80474 61644 18007 38759 85590 72172 79533 69959
    
    Expected output
    9798
    970
    8192
    4893
    0
    3291
    6692
    4579
    7251
    6792