Convex Hull (Queries)
Given a set of points on a plane and operations that modify this set, each operation can be one of the following two types:
Add a point with integer coordinates to the set. The coordinate of the new point must be strictly greater than the coordinates of all other points already in the set.
Remove the point with the largest coordinate from the set.
Write a program that simulates these operations and outputs the doubled area of the convex hull of the set of points after each operation. Initially, the set of points is empty. Assume that the area of the convex hull of an empty set of points is zero.
The convex hull of a set of points on a plane is the smallest convex polygon that contains all the points in the set. A polygon is convex if the line segment connecting any two of its points lies entirely within the polygon. Here, a polygon includes both its boundary and interior.
Input
The first line contains a single integer: – the number of operations to be performed. The next lines each contain three integers, representing the operations in an encoded format. To determine the parameters of operation number , read three integers , , and from the -th line, then calculate using the formula: , where is the doubled area of the convex hull of the set of points before executing operation . It is guaranteed that is always an integer.
If , the current operation is of the first type, and the coordinates of the new point are calculated as follows:
,
.
Here, is the maximum coordinate of all points in the set. If the set is empty, then .
If , perform the second type of operation times. The number is determined by the formula: . Here, is the number of points in the set.
It is guaranteed that with the correct decoding of all operations, the following constraints are met:
The coordinates of all points added to the set do not exceed in absolute value.
When adding a new point, its coordinate is strictly greater than the coordinates of all points already in the set.
The removal operation is applied only to a non-empty set of points.
Output
You need to output exactly lines. On line , output the doubled area of the convex hull of the set of points formed after executing the first operations. If the set of points is empty, consider the area of its convex hull to be 0.
Examples
Note
After decoding, the test looks like this:
Scoring
The test set consists of 4 separate blocks, with the following additional constraints:
15% of tests:
15% of tests:
20% of tests , with no more than 100 lines where (after decoding)
50% of tests: