#P13210. [GCJ 2016 Finals] Radioactive Islands

    ID: 15079 远端评测题 30000~60000ms 1024MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP2016Special Judge爬山算法 Local search微积分梯度下降法Google Code Jam

[GCJ 2016 Finals] Radioactive Islands

题目描述

You are steering a boat from the coordinates (10,A)(-10, A) to the coordinates (10,B)(10, B). The coordinates are measured in kilometers, and your boat travels at a constant speed of 1 kilometer per hour. You have full control over the path the boat takes. We model the boat as a single point.

There are N\mathbf{N} islands in the area; we model them as single points. The i-th island is at the coordinates (00, Ci\mathbf{C}_{\mathbf{i}}).

The area is radioactive, and you constantly receive 1 microsievert per hour of radiation from the general environment, no matter where you are. Moreover, the islands themselves are radioactive, and you constantly receive additional radiation at a rate of (Di)2(\mathbf{D}_{\mathbf{i}})^{-2} microsieverts per hour from the i-th island, where Di\mathbf{D}_{\mathbf{i}} is your current distance (in kilometers) from the i-th island. (Formally: let Di(t)\mathbf{D}_{\mathbf{i}}(\mathbf{t}) be your distance from the i-th island as a function of time t\mathbf{t}, and X\mathbf{X} be the total time your journey takes. Then the total radiation received from the i-th island is the definite integral from 00 to X\mathbf{X} of Di(t)2\mathbf{D}_{\mathbf{i}}(\mathbf{t})^{-2}.) You can get as close to an island as you would like, as long as you do not match its exact coordinates.

Find the minimum total radiation dose that you can receive if you plot your course optimally.

输入格式

The first line of the input gives the number of test cases, T\mathbf{T}; T\mathbf{T} test cases follow. Each test cases consists of two lines. The first line of a test case consists of three values: an integer N\mathbf{N}, and two floating-point numbers A\mathbf{A} and B\mathbf{B}, as described in the statement above. The second line of a test case consists of N\mathbf{N} floating-point numbers Ci\mathbf{C}_{\mathbf{i}}; the i-th of these numbers gives the y coordinate of the i-th island.

All floating-point numbers are specified to exactly two decimal places.

输出格式

For each test case, output one line containing Case #x: y, where x\mathbf{x} is the test case number (starting from 1) and y\mathbf{y} is the minimum radiation dose (in microsieverts) received while completing the journey.

y\mathbf{y} will be considered correct if it is within an absolute or relative error of 10310^{-3} of the correct answer. See the FAQ for an explanation of what that means, and what formats of real numbers we accept.

2
1 1.00 -2.00
0.00
2 0.00 0.00
3.00 -3.00
Case #1: 21.806
Case #2: 21.706

提示

Sample Explantion

Here is a diagram of the optimal path for sample case #1. We have enlarged the island to make it more visible, but remember to treat it as a single point.

Limits

  • 10.00A10.00-10.00 \leq \mathbf{A} \leq 10.00.
  • 10.00B10.00-10.00 \leq \mathbf{B} \leq 10.00.
  • 10.00Ci10.00-10.00 \leq \mathbf{C}_{\mathbf{i}} \leq 10.00, for all i\mathbf{i}.
  • $\mathbf{C}_{\mathbf{i}} \neq \mathbf{C}_{\mathbf{j}}$, for all ij\mathbf{i} \neq \mathbf{j}.

Small dataset (25 Pts, Test Set 1 - Visible)

  • Time limit: 120 30 seconds.
  • T20\mathbf{T} \leq 20;
  • N=1\mathbf{N} = 1.

Large dataset (25 Pts, Test Set 2 - Hidden)

  • Time limit: 240 60 seconds.
  • T50\mathbf{T} \leq 50;
  • 1N21 \leq \mathbf{N} \leq 2.