Codeforces Global Round 31 (Div. 1 + Div. 2)
D
Insolvable Disks
Codeforces
2000
原题
← CE →
翻译中…

You are given $n$ different integer points $x_1 \lt x_2 \lt \ldots \lt x_n$ on the X-axis of the plane. For each $1 \le i \le n$, you have to pick a real value $r_i \gt 0$ and draw a disk with radius $r_i$ and center $x_i$ such that no two disks overlap.

翻译中…

You want to choose values $r_i$ in such a way that the number of tangent pairs of disks is maximized, and you have to find this maximum value.

翻译中…

We say that two disks overlap if the area of their intersection is positive. In particular, two outer tangent disks do not overlap.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains a single integer $n$ ($1 \le n \le 2\cdot10^6$) — the number of points in that test case.

翻译中…

The second line of each test case contains $n$ integers $x_1, x_2, \ldots x_n$ ($0 \le x_1 \lt x_2 \lt \ldots \lt x_n \le 10^9$) — the coordinates of the points in that test case.

翻译中…

It's also guaranteed that the sum of $n$ over all test cases is at most $2\cdot10^6$.

翻译中…

Output

翻译中…

For each test case, print a single integer denoting the maximum number of tangent pairs of disks in that test case.

翻译中…

Note

翻译中…

In the first test case, you can let $r_1 = r_3 = 0.25$ and $r_2 = 0.75$ so the 1-st and 2-nd disks and the 2-nd and 3-rd disks will be pairwise tangent.

翻译中…

image Best solution for the first test case

翻译中…

In the second test case, you can let $r_1 = 0.4$, $r_2 = 0.6$, $r_3 = 0.2$, and $r_4 = 0.8$ so the 1-st and 2-nd disks and 3-rd and 4-th disks will be pairwise tangent.

翻译中…

image Best solution for the second test case

翻译中…

The best solution in the third test case is to set $r_i = 0.5$ for each $1 \le i \le 6$ so the 1-st and 2-nd disks, 3-rd and 4-th disks, and 5-th and 6-th disks will be pairwise tangent.

翻译中…

样例

Input #1
4
3
1 2 3
4
1 2 4 5
6
1 2 11 12 21 22
7
0 1 2 3 5 8 13
Output #1
2
2
3
6
InputCopy OutputCopy
题目信息
题号
2180D
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。