#P12119. Optimal Garbage Collection in the North Sea
Optimal Garbage Collection in the North Sea
Optimal Garbage Collection in the North Sea
The North Sea is littered with N pieces of garbage, numbered from 1 to N. The i-th piece of garbage is located at the coordinate \( (x_i, y_i) \) and has a weight of \( w_i \). As part of a cleanup operation, you are required to deploy an axis-aligned rectangular cleaning region of fixed width \( W \) and height \( H \) somewhere in the plane. The rectangle can be placed arbitrarily, and a piece of garbage is considered to be collected if its coordinate \( (x_i, y_i) \) lies within or on the boundary of the rectangle.
Your task is to determine the maximum total weight of garbage that can be collected by optimally placing the cleaning rectangle.
Note: "North Sea" refers to the part of the Atlantic Ocean and is not related to any geographical location in China.
inputFormat
The first line contains three integers \( N \), \( W \), and \( H \) representing the number of pieces of garbage, the width, and the height of the cleaning rectangle, respectively.
Each of the following \( N \) lines contains three integers \( x_i \), \( y_i \), and \( w_i \), representing the x-coordinate, y-coordinate, and weight of the \( i \)-th piece of garbage.
outputFormat
Output a single integer: the maximum total weight of garbage that can be collected by an optimally placed cleaning rectangle.
sample
3 2 2
1 2 4
2 3 5
5 5 2
9