#abc266h. Ex - Snuke Panic (2D)

Ex - Snuke Panic (2D)

Score : 600600 points

问题描述

高桥正试图捕捉许多 Snuke。

在一个二维坐标平面上存在一些坑,与 Snuke 的巢穴相连。

现在,将有 NN 只 Snuke 从这些坑中出现。已知第 ii 只 Snuke 将在时间 TiT_i 从坐标为 (Xi,Yi)(X_i, Y_i) 的坑中出现,其大小为 AiA_i

高桥在时间 00 时位于坐标 (0,0)(0,0),他可以执行以下两种类型的移动。

  • xx 轴方向(正向或负向)以不超过 11 的速度移动。
  • yy 轴方向以不超过 11 的速度移动。

不允许在负 yy 轴方向移动。

当高桥恰好在 Snuke 出现的坑的坐标位置时,他才能成功捕捉到这只 Snuke。
捕获 Snuke 所需的时间可以忽略不计。

请找出高桥通过最优移动能够捕捉到的 Snuke 的大小之和的最大值。

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

Problem Statement

Takahashi is trying to catch many Snuke.

There are some pits in a two-dimensional coordinate plane, connected to Snuke's nest.

Now, NN Snuke will appear from the pits. It is known that the ii-th Snuke will appear from the pit at coordinates (Xi,Yi)(X_i,Y_i) at time TiT_i, and its size is AiA_i.

Takahashi is at coordinates (0,0)(0,0) at time 00 and can do the following two kinds of moves.

  • Move at a speed of at most 11 in the xx-direction (positive or negative).
  • Move at a speed of at most 11 in the positive yy-direction.

Moving in the negative yy-direction is not allowed.

He can catch a Snuke appearing from a pit if and only if he is at the coordinates of that pit exactly when it appears.
The time it takes to catch a Snuke is negligible.

Find the maximum sum of the sizes of Snuke that Takahashi can catch by moving optimally.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1Ti1091 \leq T_i \leq 10^9
  • 0Xi,Yi1090 \leq X_i,Y_i \leq 10^9
  • 1Ai1091 \leq A_i \leq 10^9
  • The triples (Ti,Xi,Yi)(T_i,X_i,Y_i) are distinct.
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN

T1T_1 X1X_1 Y1Y_1 A1A_1

T2T_2 X2X_2 Y2Y_2 A2A_2

\vdots

TNT_N XNX_N YNY_N ANA_N

Output

Print the answer as an integer.

Sample Input 1

3
1 0 0 100
3 2 1 10
5 3 1 1

Sample Output 1

101

The optimal strategy is as follows.

  • Wait at coordinates (0,0)(0,0) to catch the first Snuke at time 11.
  • Go to coordinates (3,1)(3,1) to catch the third Snuke at time 55.

It is impossible to catch both the first and second Snuke, so this is the best he can.

Sample Input 2

2
100 0 1 1
200 1 0 10

Sample Output 2

10

Moving in the negative yy-direction is not allowed, so he cannot catch the first Snuke and then the second.

Sample Input 3

10
797829355 595605750 185676190 353195922
913575467 388876063 395940406 533206504
810900084 201398242 159760440 87027328
889089200 220046203 85488350 325976483
277429832 161055688 73308100 940778720
927999455 429014248 477195779 174616807
673419335 415891345 81019893 286986530
989248231 147792453 417536200 219371588
909664305 22150727 414107912 317441890
988670052 140275628 468278658 67181740

Sample Output 3

1553741733

update @ 2024/3/10 11:15:51