knightnemo commited on
Commit
1f5bf03
·
verified ·
1 Parent(s): 2c590bc

Upload code_segments/segment_262.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_262.txt +25 -0
code_segments/segment_262.txt ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Dora has just learned the programming language C++!
2
+
3
+ However, she has completely misunderstood the meaning of C++. She considers it as two kinds of adding operations on the array $c$ with $n$ elements. Dora has two integers $a$ and $b$. In one operation, she can choose one of the following things to do.
4
+
5
+ * Choose an integer $i$ such that $1 \leq i \leq n$, and increase $c_i$ by $a$. * Choose an integer $i$ such that $1 \leq i \leq n$, and increase $c_i$ by $b$.
6
+
7
+ Note that $a$ and $b$ are constants, and they can be the same.
8
+
9
+ Let's define a range of array $d$ as $\max(d_i) - \min(d_i)$. For instance, the range of the array $[1, 2, 3, 4]$ is $4 - 1 = 3$, the range of the array $[5, 2, 8, 2, 2, 1]$ is $8 - 1 = 7$, and the range of the array $[3, 3, 3]$ is $3 - 3 = 0$.
10
+
11
+ After any number of operations (possibly, $0$), Dora calculates the range of the new array. You need to help Dora minimize this value, but since Dora loves exploring all by herself, you only need to tell her the minimized value.
12
+
13
+ Each test consists of multiple test cases. The first line contains a single integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases. The description of test cases follows.
14
+
15
+ The first line of each test case contains three integers $n$, $a$, and $b$ ($1 \leq n \leq 10^5$, $1 \leq a, b \leq 10^9$) — the length of the array $c$ and the constant values, respectively.
16
+
17
+ The second line of each test case contains $n$ integers $c_1, c_2, \ldots, c_n$ ($1 \leq c_i \leq 10^9$) — the initial elements of the array $c$.
18
+
19
+ It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.
20
+
21
+ For each test case, output a single integer — the minimum possible range of the array after any number of operations.
22
+
23
+ In the first test case, we can increase $c_1 = 1$ by $a = 5$. The array $c$ will become $[6, 3, 4, 4]$, and the range is $3$. Note that there is more than one way to reach the answer.
24
+
25
+ In the second test case, we can increase $c_1 = 1$ by $a = 2$ and then increase $c_1 = 3$ by $b = 3$. Also, we can increas