QOJ.ac

QOJ

시간 제한: 1 s 메모리 제한: 1024 MB 총점: 100

#18803. Dãy số và Truy vấn 45

통계

Có một mảng $A$ có độ dài $2 \times 10^9 + 1$. Các chỉ số của $A$ là các số nguyên trong khoảng $[-10^9, 10^9]$. Ban đầu, tất cả các phần tử của $A$ đều bằng $0$ (tức là $A[-10^9] = A[-10^9+1] = \ldots = A[10^9] = 0$).

Mảng nhận $q$ truy vấn, thuộc hai loại sau:

  • 1 x y: Với mọi $-10^9 \le i \le 10^9$, đặt $A[i] = A[i] + |i - x| + y$.
  • 2: In ra vị trí $m$ của lần xuất hiện đầu tiên của giá trị nhỏ nhất của $A$, và $A[m]$. (Phần tử đầu tiên nghĩa là chỉ số nhỏ nhất.)

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên $q$ ($1 \le q \le 2 \times 10^5$).

$q$ dòng tiếp theo, mỗi dòng chứa một truy vấn thuộc một trong các dạng trên ($-10^9 \le a, b \le 10^9$).

Truy vấn đầu tiên luôn có dạng 1 x y.

Dữ liệu ra

Với mỗi truy vấn loại 2, in ra vị trí $m$ của lần xuất hiện đầu tiên của giá trị nhỏ nhất của $A$ và $A[m]$, cách nhau bởi một dấu cách.

Ví dụ

Đầu vào 1

4
1 4 2
2
1 1 -8
2

Đầu ra 1

4 2
1 -3

Đầu vào 2

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

Đầu ra 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.