#P12953. [GCJ Farewell Round #2] Spacious Sets
[GCJ Farewell Round #2] Spacious Sets
题目描述
Ada and John are best friends. Since they are getting bored, Ada asks John to solve a puzzle for her.
A set is considered spacious if the absolute difference between each pair of distinct elements of is at least , that is, for all , with .
Ada has a list of distinct integers of size , and an integer . For each , she asks John to find the maximum size of a set made of elements from , such that contains and is spacious.
Note: The sets do not need to be made of consecutive elements from the list.
输入格式
The first line of the input gives the number of test cases, . test cases follow. The first line of each test case contains two integers and . The next line contains integers $\mathbf{A}_1 \mathbf{A}_2 \ldots \mathbf{A}_{\mathbf{N}}$.
输出格式
For each test case, output one line containing Case # : , where is the test case number (starting from 1) and is the maximum size of a spacious set of elements from that contains .
2
3 2
1 2 3
6 4
2 7 11 19 5 3
Case #1: 2 1 2
Case #2: 4 4 4 4 3 4
提示
Sample Explanation
In Sample Case #1, a spacious set cannot contain and , nor it can contain and . That implies that and using makes them of maximum size.
In Sample Case #2, possible sets of maximum size are:
- ,
- , and
- .
Limits
- .
- , for all .
- , for all .
Test Set 1 (4 Pts, Visible Verdict)
- .
- .
Test Set 2 (10 Pts, Visible Verdict)
- .
For at most 15 cases:
- .
For the remaining cases:
- .