14324 - Closest Value II   

Description

Given two arrays \(a\) and \(b\), each contains \(N\) elements. Additionally, you are given a target value \(x\) and a len \(L\).

For each element \(a_i\) in \(a\), you have to find the index \(j\) of an element \(b_j\), such that the sum \(a_i + b_j\) is as close to \(x\) as possible. Also, the search for \(b_j\) is limited to a contiguous range of elements starting from \(b_i\) and extending up to L elements or until the end of array b, whichever comes first. (i.e. \(i \le j \le min(N, i + L) - 1\))

If there are multiple \(b_j\) result in the same closest sum to \(x\), you need to output the smallest index \(j\).

Input

The first line contains three integers \(N, L, x\).
The second line contains \(N\) integers \(a_0, a_1 \dots a_{N - 1}\)
The third line contains \(N\) integers \(b_0, b_1 \dots b_{N - 1}\)

\(N \quad L \quad x\)
\(a_0 \quad a_1 \dots a_{N - 1}\)
\(b_0 \quad b_1 \dots b_{N - 1}\)

Constraints

  • \(1 \le N, L \le 2 * 10^5\)
  • \(1 \le a_i, b_i, x \le 10^9\)

Output

Please output the answer of each query.

Sample Input  Download

Sample Output  Download

Tags




Discuss