QOJ.ac

QOJ

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

#18803. 数列とクエリ 45

İstatistikler

長さ $2 \times 10^9 + 1$ の配列 $A$ があります。$A$ の添え字は $[-10^9, 10^9]$ の範囲の整数です。最初、$A$ のすべての要素は $0$ です(すなわち $A[-10^9] = A[-10^9+1] = \ldots = A[10^9] = 0$)。

この配列に対して $q$ 個のクエリが与えられます。クエリは以下の 2 種類です。

  • 1 x y: すべての $-10^9 \le i \le 10^9$ について、$A[i] = A[i] + |i - x| + y$ と設定する。
  • 2: $A$ の最小値が最初に現れる位置 $m$ と、$A[m]$ を出力する。(最初に現れるとは、添え字が最小であることを意味する。)

入力

最初の行には整数 $q$ ($1 \le q \le 2 \times 10^5$) が含まれる。

次の $q$ 行には、それぞれ上記の形式のいずれかのクエリが含まれる ($-10^9 \le a, b \le 10^9$)。

最初のクエリは常に 1 x y の形式である。

出力

タイプ 2 のクエリごとに、$A$ の最小値が最初に現れる位置 $m$ と $A[m]$ を空白区切りで出力せよ。

入出力例

入力例 1

4
1 4 2
2
1 1 -8
2

出力例 1

4 2
1 -3

入力例 2

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

出力例 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.