#abc274f. F - Fishing

F - Fishing

Score : 500500 points

问题描述

在数轴上,有 NN 条鱼在游动。

ii 条鱼的重量为 WiW_i,在时间 00 时刻位于坐标 XiX_i 处,并以速度 ViV_i 向正方向移动。

高桥将选择一个大于等于 00 的任意实数 tt,并在时间 tt 仅执行一次以下动作:

动作:选择一个任意实数 xx。捕获所有坐标位于 xxx+Ax+A(包含两端点)之间的鱼。

请找出他能捕获的最大总重量的鱼。

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

Problem Statement

On a number line, there are NN fish swimming.

Fish ii, which has a weight of WiW_i, is at the coordinate XiX_i at time 00 and moves at a speed of ViV_i in the positive direction.

Takahashi will choose an arbitrary real number tt greater than or equal to 00 and do the following action at time tt just once.
Action: Choose an arbitrary real number xx. Catch all fish whose coordinates are between xx and x+Ax+A, inclusive.

Find the maximum total weight of fish that he can catch.

Constraints

  • 1N20001 \leq N \leq 2000
  • 1A1041 \leq A \leq 10^4
  • 1Wi1041 \leq W_i\leq 10^4
  • 0Xi1040 \leq X_i\leq 10^4
  • 1Vi1041 \leq V_i\leq 10^4
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN AA

W1W_1 X1X_1 V1V_1

W2W_2 X2X_2 V2V_2

\vdots

WNW_N XNX_N VNV_N

Output

Print the answer.

Sample Input 1

3 10
100 0 100
1 10 30
10 20 10

Sample Output 1

111

At time 0.250.25, fish 11, 22, and 33 are at the coordinates 2525, 17.517.5, and 22.522.5, respectively. Thus, the action done at this time with x=16x=16 catches all the fish.

Sample Input 2

3 10
100 100 100
1 10 30
10 20 10

Sample Output 2

100

One optimal choice is to do the action at time 00 with x=100x=100.

Sample Input 3

4 10
1000 100 10
100 99 1
10 0 100
1 1 1

Sample Output 3

1110

One optimal choice is to do the action at time 11 with x=100x=100.

update @ 2024/3/10 11:33:14

}