Under construction

Still being built. Things may change

The Silk Road with Robots

Time limit5sMemory limit1024 MB

Summary
After each day, report the maximum total profit from sending robots to stores, where a robot pays 1 tenge per meter moved and collects each store's tenges once.
Level

Hard9 of 10

Topics
Segment tree, Greedy, Sorting
Solved
No attempts yet

Problem

Parts of the ancient silk road passed through southern Kazakhstan. You have been fantasizing about a modern silk road, which has its own special features. Along your fantasy road are robots as well as stores holding stashes of tenges (the national currency of Kazakhstan). If a robot moves to a location with a store, the robot collects all of that store's tenges for you.

The cost of moving a robot is 11 tenge for every meter moved. So the amount of profit from moving a robot to a store is the number of tenges held by the store minus the number of meters the robot has moved to reach the store.

Consider this scenario, which unfolds over several days. Initially, the road is empty, with no robots or stores. Every day, either a new robot or a new store is placed on an unoccupied location along the road. Immediately before that, each existing store on the road is resupplied with tenges so that its total amount is the same as when it was first placed on the road, and each robot is returned to its original starting location.

For each day, you need to determine the maximum amount of profit that could be gained by moving robots to collect tenges from the stores. Note that no two robots start in the same location, but they may occupy the same location as they move. Each store can be emptied of its tenges only once during a single day.

Input

The first line contains an integer nn (1≤n≤2⋅1051 ≤ n ≤ 2 \cdot 10^5), the number of days. This is followed by nn lines. The iith line starts with an integer tit_i, which is equal to 11 if a new robot is added on day ii, or equal to 22 if a new store is added that day. It is followed by an integer xix_i (0≤xi≤1080 ≤ x_i ≤ 10^8), denoting the location of the new robot or the new store. If ti=2t_i = 2, the line contains another integer cic_i (0≤ci≤1080 ≤ c_i ≤ 10^8), denoting the number of tenges at the store. All the given locations are distinct.

Output

Output nn integers. The iith integer is the maximum profit you can make after day ii.

Examples1

  1. Example 1

    Input
    6
    1 20
    2 15 15
    2 40 50
    1 50
    2 80 20
    2 70 30
    
    Expected output
    0
    10
    35
    50
    50
    60