#P16618. [GKS 2017 #B] Center

    ID: 16573 Type: RemoteJudge 2000ms 1024MiB Tried: 0 Accepted: 0 Difficulty: 6 Uploaded By: Tags>数学贪心2017Special JudgeGoogle Kick Start

[GKS 2017 #B] Center

题目描述

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.

输入格式

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.

输出格式

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

提示

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.