#P2280. [HNOI2003] 激光炸弹

    ID: 1251 远端评测题 1000ms 500MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>动态规划,dp2003各省省选湖南枚举,暴力前缀和

[HNOI2003] 激光炸弹

Description

A new type of laser bomb can destroy all targets inside a square with side length mm. There are nn targets on the map. Integers xix_i and yiy_i denote the position of a target on the map, and each target has a value viv_i. The bomb is aimed via satellite, but it has a drawback: the blast square, i.e., the square of side length mm, must have its sides parallel to the x-axis and y-axis. If a target lies on the boundary of the blast square, it will not be destroyed.

Your task is to compute the maximum total value of targets that a single bomb can destroy.

Multiple targets may be located at the same position.

Input Format

The first line contains integers nn and mm.

Each of the next nn lines contains three integers x,y,vx, y, v, denoting a target’s coordinates and its value.

Output Format

Output a single positive integer, the maximum total value of targets that can be destroyed by one bomb (the result does not exceed 32767).

2 1
0 0 1
1 1 1

1

Hint

  • Constraints
    • For 100%100\% of the testdata, it is guaranteed that 1n1041 \le n \le 10^4, 0xi,yi5×1030 \le x_i , y_i \le 5\times 10^3, 1m5×1031 \le m \le 5\times 10^3, 1vi<1001 \le v_i < 100.

Translated by ChatGPT 5