#P10455. Genius Acm

Genius Acm

Problem Description

Advanced CPU Manufacturer (ACM) is one of the best CPU manufacturers in the world. Every day, the company produces nn CPUs and sells them all over the world.

ACM's quality inspection department tests the produced CPUs in groups. The testing method for one group (several CPUs) is as follows:

  1. Randomly select mm pairs of CPUs (i.e., 2m2m CPUs) from the group. If the total number is less than 2m2m, select as many pairs as possible.

  2. For each pair of CPUs, measure their Relative Performance Difference (RPD), and denote the RPD of the ii-th pair as DiD_i. The definition of RPD is given later.

  3. The Squared Performance Difference (SPD) of this group of CPUs is given by:

SPD=iDi2SPD=\sum _i D^2_i

  1. This group of CPUs passes the quality inspection if and only if SPDk,SPD \le k, where kk is a given constant.

The CPUs produced by ACM have very good performance, but the standards made by the quality inspection department are even too strict. Usually, they test all nn CPUs as one single group, which causes some good CPUs to fail the test, and the production department complains about it. As the leader of the quality inspection department, Xiao S came up with an idea without changing the testing process: if the nn CPUs can be properly divided into several consecutive segments, and every segment can pass the group test, then the current problem can be solved.

Now, Xiao S already knows the performance values P1,,PnP_1,\cdots ,P_n of the nn CPUs. The RPD of two CPUs is defined as the absolute value of the difference between their performance values. Please help compute the minimum number of segments to divide these CPUs into, so that every segment can pass the group test.

Input Format

Each test point contains multiple test cases. The first line contains an integer TT, the number of test cases.

For each test case, the first line contains three integers n,m,kn,m,k. The second line contains nn integers P1,,PnP_1,\cdots ,P_n.

Output Format

For each test case, output one integer representing the answer.

2
5 1 49
8 2 1 7 9
5 1 64
8 2 1 7 9
2
1

Hint

For 20%20\% of the testdata, 1n1021 \leq n \leq 10^2
For 40%40\% of the testdata, 1n1031 \leq n \leq 10^3
For another 10%10\% of the testdata, k=0k=0
For another 10%10\% of the testdata, 0k10 \leq k \leq 1
For another 10%10\% of the testdata, m=1m=1
For another 10%10\% of the testdata, 1m21 \leq m \leq 2
For 90%90\% of the testdata, 0k10120 \leq k \leq 10^{12}
For 100%100\% of the testdata, $T \leq 12,1 \leq n, m \leq 5 \cdot 10^5, 0 \leq k \leq 10^{18}, 0 \leq P_i \leq 2^{20}$。

Translated by ChatGPT 5