#P17533. [JAG 2026 Summer Camp #1] Longest Symmetry
[JAG 2026 Summer Camp #1] Longest Symmetry
Problem Description
There are houses numbered on a number line. House is located at coordinate . It is guaranteed that for every ().
For integers with , we say that the consecutive houses form a symmetric interval of houses if the following condition holds:
- For every , holds.
You are given queries. Process them in order.
- In the -th query, you are given integers (). Among all pairs of integers satisfying such that the consecutive houses form a symmetric interval of houses, output the maximum possible width of the interval.
Input Format
The input consists of a single test case of the following format:
N
X_1 X_2 ... X_N
Q
l_1 r_1
l_2 r_2
...
l_Q r_Q
The first line contains an integer , representing the number of houses ().
The second line contains integers , representing the coordinates of the houses (). It is guaranteed that for every ().
The third line contains an integer , representing the number of queries ().
Each of the following lines contains two integers and , representing the left and right endpoints of the range specified in the -th query ().
Output Format
For each query, output the maximum possible width.
7
-5 -2 0 4 6 9 12
5
1 7
2 6
3 7
4 7
3 6
14
8
6
6
4