#P14621. [2019 KAIST RUN Fall] Parklife

    ID: 14381 远端评测题 1500ms 1024MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>贪心2019高校校赛启发式合并

[2019 KAIST RUN Fall] Parklife

题目描述

:::align{center}

Gapcheon and an Expo bridge in a cloudy day :::

Gapcheon\textit{Gapcheon} is a stream that flows through the Daedeok Innopolis\textit{Daedeok Innopolis}: A research district in Daejeon which includes KAIST, Expo Science Park, National Science Museum, among many others. The waterfront of Gapcheon is used as a park, which is a facility for leisure and recreation.

In this problem, we model the Gapcheon\textit{Gapcheon} as a slightly curved arc. In the arc, there are exactly 10610^6 points marked by each centimeter. In Gapcheon\textit{Gapcheon}, there are NN bridges that connect two distinct points in the arc in a straight line segment. Such a line segment may touch other segments in an endpoint but never crosses them otherwise. For each pair of points, there exists at most one bridge that directly connects those two points.

:::align{center}

x,y,zx, y, z are bridges that do not cross but only touch each other in an endpoint. This can be a possible input instance. Points with number 81068 \ldots 10^6 are omitted for brevity. :::

:::align{center}

x,yx, y are bridges that cross each other. This is not a possible input instance. Points with number 81068 \ldots 10^6 are omitted for brevity. :::

The city council is planning to place some lights in the bridges, to make Gapcheon as a more enjoyable place in the night. For each bridge, the city council calculated the aesthetical value if the lights are installed in these bridges. These value can be represented as a positive integer.

However, too many lightings will annoy the residents at midnight. To address this issue, the council decided to make some regulations: for every arc between two adjacent points, there should be at most kk lighted bridges visible from there. We call a line segment visible\textbf{visible} from an arc connecting i,i+1i, i+1, when one endpoint of the segment has an index at most ii, and another endpoint of the segment has an index at least i+1i+1.

The city council wants to consider the tradeoff between light pollution and the night view, so you should provide the maximum possible sum of aesthetical value, for all integers 1kN1 \le k \le N.

输入格式

The first line contains an integer NN. (1N2500001 \le N \le 250\,000)

The next NN lines contain three integers Si,Ei,ViS_i, E_i, V_i, which denotes there is a straight line bridge connecting points Si,EiS_i, E_i, and having aesthetic value ViV_i. (1Si<Ei106,1Vi1091 \le S_i < E_i \le 10^6, 1 \le V_i \le 10^9).

It's guaranteed that no lines connect the same pair of points, and no two different line segments cross.

输出格式

Print NN integers separated by a space. The ii-th integer (1iN1 \le i \le N) should be the answer if k=ik = i.

6
1 2 10
2 3 10
1 3 21
3 4 10
4 5 10
3 5 19
41 80 80 80 80 80
4
1 5 1
2 5 1
3 5 1
4 5 1
1 2 3 4

提示

:::align{center}

Depiction of Sample Input 1. :::

Copyright notice for Figure 1: 사진제공(한국관광공사 김지호)-한국관광공사