atcoder#ABC244H. [ABC244Ex] Linear Maximization
[ABC244Ex] Linear Maximization
Score : points
Problem Statement
There is a set of points on a two-dimensional plane. is initially empty.
For each in this order, process the following query.
- You are given integers , and . Add point to , and then find $\displaystyle \max_{(x,y) \in S}\left\{A_ix + B_iy\right\}$.
Constraints
- All values in input are integers.
- If , then .
Input
Input is given from Standard Input in the following format:
Output
Print lines. The -th line should contain the answer for the -th query.
4
1 0 -1 -1
0 1 2 0
-1 0 1 1
0 -1 1 -2
-1
2
1
2
- When : add point to , then it will become . For , we have , which is the maximum.
- When : add point to , then it will become . For , we have , which is the maximum.
- When : add point to , then it will become . For or , we have , which is the maximum.
- When : add point to , then it will become . For , we have , which is the maximum.
9
-1 4 -8 -2
9 -9 -7 7
4 1 6 7
-4 -1 -4 -5
-9 3 -2 -6
-1 0 -8 5
-8 -5 0 0
8 3 0 -4
2 -5 2 5
0
35
31
21
36
87
0
36
31