CF2180D.Insolvable Disks
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given n different integer points x1<x2<…<xn on the X-axis of the plane. For each 1≤i≤n, you have to pick a real value ri>0 and draw a disk with radius ri and center xi such that no two disks overlap.
You want to choose values ri 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.
给定平面上 x 轴上的 n 个互不相同的整数点 x1<x2<…<xn。对每个 1≤i≤n,你需要选择一个实数 ri>0,并以 xi 为圆心、ri 为半径画一个圆盘,使得任意两个圆盘互不重叠。
你需要选择这些 ri 的值,使得相切的圆盘对数最大化,并求出该最大值。
我们称两个圆盘重叠,当且仅当它们的交集面积为正。特别地,两个外切圆盘不视为重叠。
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The first line of each test case contains a single integer n (1≤n≤2⋅106) — the number of points in that test case.
The second line of each test case contains n integers x1,x2,…xn (0≤x1<x2<…<xn≤109) — 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⋅106.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例的第一行包含一个整数 n(1≤n≤2⋅106)—— 表示该测试用例中点的数量。
每个测试用例的第二行包含 n 个整数 x1,x2,…,xn(0≤x1<x2<…<xn≤109)—— 表示该测试用例中各点的坐标。
此外,保证所有测试用例的 n 值之和不超过 2⋅106。
输出格式
For each test case, print a single integer denoting the maximum number of tangent pairs of disks in that test case.
对于每个测试用例,输出一个整数,表示该测试用例中圆盘的相切对的最大数量。
输入输出样例
输入#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
输出#1
2 2 3 6
说明/提示
In the first test case, you can let r1=r3=0.25 and r2=0.75 so the 1-st and 2-nd disks and the 2-nd and 3-rd disks will be pairwise tangent.
Best solution for the first test case
In the second test case, you can let r1=0.4, r2=0.6, r3=0.2, and r4=0.8 so the 1-st and 2-nd disks and 3-rd and 4-th disks will be pairwise tangent.
Best solution for the second test case
The best solution in the third test case is to set ri=0.5 for each 1≤i≤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.
在第一个测试用例中,你可以令 r1=r3=0.25 且 r2=0.75,使得第 1 个与第 2 个圆盘、以及第 2 个与第 3 个圆盘两两相切。
第一个测试用例的最优解
在第二个测试用例中,你可以令 r1=0.4、r2=0.6、r3=0.2、r4=0.8,使得第 1 个与第 2 个圆盘、以及第 3 个与第 4 个圆盘两两相切。
第二个测试用例的最优解
第三个测试用例的最优解是:对每个 1≤i≤6,均设 ri=0.5,使得第 1 个与第 2 个圆盘、第 3 个与第 4 个圆盘、以及第 5 个与第 6 个圆盘两两相切。
输入解题思路,AI测评打分。不知道怎么写?