#P16618. [GKS 2017 #B] Center

    ID: 18974 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学贪心2017Special JudgeGoogle Kick Start

[GKS 2017 #B] Center

Problem Description

There are NN weighted points in a plane. Point ii is at (XiX_i, YiY_i) and has weight WiW_i.

In this problem, we need to find a special center of these points. The center is a point (XX, YY) such that the sum of max(XXi,YYi)×Wi\max(|X-X_i|, |Y-Y_i|) \times W_i is minimum.

Input Format

The input starts with one line containing exactly one integer TT, which is the number of test cases. TT test cases follow.

Each test case begins with one line containing one integer NN. NN lines follow. Each line contains three space-separated real numbers XiX_i, YiY_i, and WiW_i. XiX_i, YiY_i and WiW_i have exactly 2 digits after the decimal point.

Output Format

For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is the sum of max(XXi,YYi)×Wi\max(|X-X_i|, |Y-Y_i|) \times W_i for center (XX, YY).

yy will be considered correct if it is within an absolute or relative error of 10610^{-6} of the correct answer.

3
2
0.00 0.00 1.00
1.00 0.00 1.00 
4
1.00 1.00 1.00
1.00 -1.00 1.00
-1.00 1.00 1.00
-1.00 -1.00 1.00 
2
0.00 0.00 1.00
1.00 0.00 2.00
Case #1: 1.0
Case #2: 4.0
Case #3: 1.0

Hint

Limits

1T101 \le T \le 10.

1000.00Xi1000.00-1000.00 \le X_i \le 1000.00.

1000.00Yi1000.00-1000.00 \le Y_i \le 1000.00.

Small dataset (Test set 1 - Visible)

1N1001 \le N \le 100;

Wi=1.0W_i = 1.0, for all i.

Large dataset (Test set 2 - Hidden)

1N100001 \le N \le 10000;

1.0Wi1000.01.0 \le W_i \le 1000.0, for all i.