QOJ.ac

QOJ

Süre Sınırı: 1 s Bellek Sınırı: 1024 MB Toplam puan: 100

#18803. Sequence and Queries 45

İstatistikler

There is an array $A$ of length $2 \times 10^9 + 1$. The indices of $A$ are integers in the range $[-10^9, 10^9]$. Initially, all elements of $A$ are $0$ (i.e., $A[-10^9] = A[-10^9+1] = \ldots = A[10^9] = 0$).

The array receives $q$ queries, which are of the following two types:

  • 1 x y: For all $-10^9 \le i \le 10^9$, set $A[i] = A[i] + |i - x| + y$.
  • 2: Output the position $m$ of the first occurrence of the minimum value of $A$, and $A[m]$. (First occurrence means the smallest index.)

Input

The first line contains an integer $q$ ($1 \le q \le 2 \times 10^5$).

The next $q$ lines each contain a query in one of the above forms ($-10^9 \le a, b \le 10^9$).

The first query is always of the form 1 x y.

Output

For every query of type 2, output the position $m$ of the first occurrence of the minimum value of $A$ and $A[m]$, separated by a space.

Examples

Input 1

4
1 4 2
2
1 1 -8
2

Output 1

4 2
1 -3

Input 2

4
1 -1000000000 1000000000
1 -1000000000 1000000000
1 -1000000000 1000000000
2

Output 2

-1000000000 3000000000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.