#P12564. [UTS 2024] Jobs

[UTS 2024] Jobs

题目描述

You are given a set of nn points with integer coordinates. Each point has its own weight.

We can split the plane using a point of coordinates (x,y)(x, y) into four dials by drawing the vertical line in x+0.5x + 0.5 and the horizontal line in y+0.5y + 0.5. We define the weight of a dial to be the sum of the weights of all the points in that dial. Furthermore, the imbalance\underline{\text{imbalance}} of such a split is the maximum difference between the weight of two of its dials.

For each integer xx such that 1x<n1 \leq x < n, find the minimum imbalance of a split that uses a point on the vertical line xx.

输入格式

The first line contains an integer nn (1n21051 \leq n \leq 2 \cdot 10^5).

Each of the next nn lines contains three integers xix_i, yiy_i, and wiw_i (1xi,yin1 \leq x_i, y_i \leq n, 1wi1091 \leq w_i \leq 10^9) --- the coordinates and weight of the ii-th point.

输出格式

The only line of the output should contain n1n - 1 integers, the required minimum imbalances.

4
3 2 5
4 4 2
1 4 4
2 2 1
6
4
6

提示

  • (77 points): 1n2001 \leq n \leq 200;
  • (1717 points): 1n50001 \leq n \leq 5000;
  • (5353 points): 1n1000001 \leq n \leq 100\,000;
  • (2323 points): no further restrictions.