P27175 [AtCoder] I like you...
NOI
题目描述

Problem Description

In the Iroha world, it is well-known that Iroha-chan places and removes tens of thousands of coins on a number line.

Initially, there are no coins on the number line.
Iroha-chan will perform $ Q $ operations in sequence. There are three types of operations:

  • Addition: Place a $ v $-yen coin at coordinate $ x $ on the number line. It is guaranteed that there is no coin at coordinate $ x $ at this point.
  • Removal: Remove the coin at coordinate $ x $ on the number line. It is guaranteed that there is a coin at coordinate $ x $ at this point.
  • Command: Place Hirakichi-kun at coordinate $ x $ and have him pick up one coin. Hirakichi-kun will always pick the coin that maximizes the "efficiency". The "efficiency" when picking a $ w $-yen coin at coordinate $ c $ is $\frac{w}{|c-x|}$. Here, $ |t| $ denotes the absolute value of $ t $.

For example, if there is a 3-yen coin at coordinate 2 and an 8-yen coin at coordinate 5, the maximum efficiency in each case is as follows:

  • If Hirakichi-kun is placed at coordinate 0, he will pick the coin at coordinate 5 with an efficiency value of 1.6.
  • If Hirakichi-kun is placed at coordinate 1, he will pick the coin at coordinate 2 with an efficiency value of 3.0.
  • If Hirakichi-kun is placed at coordinate 7, he will pick the coin at coordinate 5 with an efficiency value of 4.0.

Note that the coin picked by the command is immediately returned to its original place by Iroha-chan's skill, so Hirakichi-kun may pick the same coin more than once.

For each command operation, find the efficiency value of Hirakichi-kun's movement in sequence.
If there are no coins on the number line at the time of the command operation, the efficiency value is 0.

Input Format

The input is given from the standard input in $ Q + 1 $ lines in the following format:

$ Q $ ($ 1 $st operation information) ($ 2 $nd operation information) ($ 3 $rd operation information) ... ($ Q $th operation information)

For the addition operation, the line is given as follows:

$ 1 $ $ x $ $ v $

For the removal operation, the line is given as follows:

$ 2 $ $ x $

For the command operation, the line is given as follows:

$ 3 $ $ x $

Output Format

For all command operations, output the maximum efficiency value of Hirakichi-kun's optimal movement in sequence.
The absolute or relative error is allowed up to $ 10^{-5} $.

Sample Input and Output

Sample Input #1

11
1 2 3
3 10
1 5 8
3 0
3 1
3 7
2 2
1 7 9
3 3
3 6
3 10

Sample Output #1

0.375000000000
1.600000000000
3.000000000000
4.000000000000
4.000000000000
9.000000000000
3.000000000000

Sample Input #2

10
1 0 10
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9

Sample Output #2

10.000000000000
5.000000000000
3.333333333333
2.500000000000
2.000000000000
1.666666666667
1.428571428571
1.250000000000
1.111111111111

Notes/Hints

Story

"I like you..."

A sealed envelope I received on the way home from Iroha-chan. It is sealed with a cute heart sticker. Inside was this problem.
"Iroha-chan, you really are the true final boss..."

Constraints

  • All inputs are integers.
  • $1 \leq Q \leq 3 \times 10^5$
  • $0 \leq x \leq 10^9$
  • $0 \leq v \leq 10^9$
  • For all addition operations, there is no coin at the coordinate where the coin is to be added.
  • For all removal operations, there is a coin at the coordinate where the coin is to be removed.
  • For all command operations, there is no coin at the coordinate where Hirakichi-kun is placed.

Partial Points

This problem has partial points as follows:

  • Correctly solving all test cases where $Q \leq 120000$ gives 1100 points.
  • Correctly solving all test cases gives an additional 300 points.

Explanation

Explanation

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
11 1 2 3 3 10 1 5 8 3 0 3 1 3 7 2 2 1 7 9 3 3 3 6 3 10
样例输出
0.375000000000 1.600000000000 3.000000000000 4.000000000000 4.000000000000 9.000000000000 3.000000000000