Do you order queries?
Practice
3 (16 votes)
Advanced data structures
Data structures
Segment trees
Problem
92% Success 847 Attempts 50 Points 2.5s Time Limit 1500MB Memory 1024 KB Max Code

You are given n ($1$ $\le$ $n$ $\le$ $300000$) queries. Each query is one of $3$ types:

1. add pair ($a$, $b$) to the set. ($-10^9$ $\le$ $a, b$ $\le$ $10^9$)

2. remove a pair added in query $index$ (All queries are numbered with integers from $1$ to $n$).

3. For a given integer $A$ find the maximal value $a·A + b$ over all pairs ($a$, $b$) from the set. ($-10^9$ $\le$ $A$ $\le$ $10^9$). It is guaranteed that the set of pair will not be *empty*.

 

INPUT.

 

The first line contains integer $n$ ($1$ $\le$ $n$ $\le$ $3·10^5$) - the number of queries.

Each of next $n$ lines starts with integer $op$ ($1$ $\le$ $op$ $\le$ $3$) - the type of query.

 

OUTPUT

For each query of $3$ type print on a separate line the maximal value of $a·A + b$. It is guaranteed that the set of pair will not be *empty*.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:50
3 votes
Tags:
Inclusion-exclusionData StructuresSegment TreesAdvanced Data StructuresBasic ProgrammingNumber theoryCombinatoricsMath
Points:50
2 votes
Tags:
Advanced Data StructuresSegment TreesData Structures
Points:50
5 votes
Tags:
Dynamic ProgrammingSegment TreesAdvanced Data StructuresSegment treeData Structures