#abc220g. G - Isosceles Trapezium

G - Isosceles Trapezium

Score : 600600 points

问题描述

xyxy 平面中,我们有 NN 个点,每个点都被赋予一个权重。 第 ii 个点的坐标为 (Xi,Yi)(X_i,Y_i),其权重为 CiC_i

我们将从这 NN 个点中选出四个点,以形成一个顶点为所选点的等腰梯形。
所选点的最大可能总权重是多少?

如果无法构成一个等腰梯形,则输出 -1

我们提醒您,等腰梯形是一个满足以下所有条件的四边形:

  • 它是一个梯形。
  • 对于其中一对平行边,其两端的两个角是相等的。

以上为通义千问 qwen-max 翻译,仅供参考。

Problem Statement

In the xyxy-plane, we have NN points, each assigned a weight.
The ii-th point has the coordinates (Xi,Yi)(X_i,Y_i) and the weight CiC_i.

We will choose four of the NN points to form an isosceles trapezoid whose vertices are the chosen points.
What is the maximum possible total weight of the points chosen here?

If it is impossible to form an isosceles trapezoid, print -1.

We remind you that an isosceles trapezoid is a quadrilateral that satisfies all of the following conditions.

  • It is a trapezoid.
  • For one of the two parallel sides, the two angles at its ends are equal.

Constraints

  • 4N10004 \leq N \leq 1000
  • 109Xi,Yi109-10^9 \leq X_i,Y_i \leq 10^9
  • 1Ci1091 \leq C_i \leq 10^9
  • (Xi,Yi)(Xj,Yj)(X_i,Y_i) \neq (X_j,Y_j) if iji \neq j.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

X1X_1 Y1Y_1 C1C_1

X2X_2 Y2Y_2 C2C_2

\vdots

XNX_N YNY_N CNC_N

Output

Print the answer.

Sample Input 1

5
0 3 10
3 3 10
-1 0 10
2 0 10000
4 0 10

Sample Output 1

40

We can choose Points 1,2,3,51, 2, 3, 5 to form an isosceles trapezoid, with the points having a total weight of 4040.
Any other way to choose points would not form an isosceles trapezoid.

Sample Input 2

6
0 1 1
1 4 20
2 7 300
5 6 4000
4 3 50000
3 0 600000

Sample Output 2

650021

Note that a square and a rectangle are also isosceles trapezoids.

Sample Input 3

7
-3 0 1
-2 0 1
-1 0 1
0 0 1
1 0 1
2 0 1
3 0 1

Sample Output 3

-1

We cannot form an isosceles trapezoid.

update @ 2024/3/10 09:44:11