Under construction

Still being built. Things may change

Painting the Fence

Time limit2sMemory limit1024 MB

Summary
After each prefix of n painted segments, report the largest visible color, where overlapping segments merge into groups colored by their mean.
Level

Medium7 of 10

Topics
Intervals, Segment tree, Union-find
Solved
No attempts yet

Statement

Young Anakin Skywalker received a seemingly simple task from Master Yoda. He has to paint a fence with a special paint. The task consists of nn subtasks. Each subtask paints a segment of the fence with a given color. Colors are integers. Like any other paint, the paint Anakin got changes its color after it dries, but in an unusual way. Two segments intersect if their intersection has nonzero area. At first, each painted segment is its own group. While there are two intersecting segments that belong to different groups AA and BB, merge AA and BB. Repeat until no such pair remains. The color of a group is the arithmetic mean of the colors of its segments. Knowing this value for each group, we can find the color of any point of the fence after the paint dries. A point belongs to a group if at least one segment of that group contains it. A point that belongs to no group has color 00. Otherwise it has the color of its group. A point cannot belong to two groups. While painting, Anakin wondered what happens if he finishes after the first ii segments are painted. In particular, he asked: what is the largest color that can be found on the fence after the paint dries?

Input

The first line contains one integer nn (1≤n≤1051 \le n \le 10^5), the number of fence segments to paint. Each of the next nn lines contains three integers ll, rr, cc (0≤l<r≤1090 \le l < r \le 10^9, 1≤c≤1091 \le c \le 10^9). The segment is [l,r)[l, r), so the left end ll is included and the right end rr is not. cc is the color used to paint this segment.

Output

Print nn real numbers, one per line, with at least three digits after the decimal point. The number on line ii is the largest color of a point on the fence that can be found if Anakin finishes after the first ii subtasks.

Examples1

  1. Example 1

    Input
    6
    0 1 1
    2 5 2
    3 7 3
    6 8 4
    9 11 5
    7 10 6
    
    Expected output
    1.00000
    2.00000
    2.50000
    3.00000
    5.00000
    4.00000