F - Absolute Minima
Time Limit: 2 sec / Memory Limit: 1024 MB
Score : 600600 points
Problem Statement
There is a function f(x)f(x), which is initially a constant function f(x)=0f(x)=0.
We will ask you to process QQ queries in order. There are two kinds of queries, update queries and evaluation queries, as follows:
- An update query
1 a b
: Given two integers aa and bb, let g(x)=f(x)+|x−a|+bg(x)=f(x)+|x−a|+b and replace f(x)f(x) with g(x)g(x). - An evaluation query
2
: Print xx that minimizes f(x)f(x), and the minimum value of f(x)f(x). If there are multiple such values of xx, choose the minimum such value.
We can show that the values to be output in an evaluation query are always integers, so we ask you to print those values as integers without decimal points.