#FT0000046. Giá trị tuyệt đối nhỏ nhất (Absolute Minima)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Giá trị tuyệt đối nhỏ nhất (Absolute Minima)
Absolute Minima
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A real-valued function is initially zero for every real . Process operations:
1 a b: replace the current function by , adding this expression for every .2: find an minimizing and print that together with the minimum value . If multiple values minimize the function, choose the smallest .
The first operation is guaranteed to be type 1, so at least one absolute-value term exists before any evaluation. The required output values are integers.
Input
- Line 1: integer , the operation count.
- Next lines: a type-
1operation has three integers1 a b; a type-2operation contains only the integer2.
Output
For each type-2 operation, print two integers on one line, where is the smallest minimizer and is the minimum value.
Subtasks
Subtask 1 (20 points):
- ; in every
1 a boperation; every operation is type1or2; the first operation is type1; all input values are integers.
Subtask 2 (30 points):
- ; in every
1 a boperation; every operation is type1or2; the first operation is type1; all input values are integers.
Subtask 3 (50 points):
- ; in every
1 a boperation; every operation is type1or2; the first operation is type1; all input values are integers.
Examples
Examples 1
Input
4
1 4 2
2
1 1 -8
2
Output
4 2
1 -3
Explanation
After 1 4 2, has minimum at . After 1 1 -8, . For every in , the absolute-value sum is , so the minimum is . The smallest minimizing is .
Examples 2
Input
4
1 -1000000000 1000000000
1 -1000000000 1000000000
1 -1000000000 1000000000
2
Output
-1000000000 3000000000
Explanation
All three absolute-value terms vanish at . The three constants each contribute , making the minimum , which requires a 64-bit integer.