QOJ.ac

QOJ

حد الوقت: 2 s حد الذاكرة: 512 MB مجموع النقاط: 100

#9609. Humor or Dream

الإحصائيات

There are $n$ purchase plans. The $i$-th plan is as follows:

  1. Spend $a_i$ to purchase one item;
  2. Spend $b_i$ to purchase two items.

The two options cannot be chosen simultaneously, and each plan can be executed at most once. Given $q$ operations:

  • 1 p x y: $a_p \leftarrow x, b_p \leftarrow y$
  • 2 l r k: Only plans $i \in [l, r]$ can be executed. What is the minimum cost to purchase $k$ items?

Input

Two integers $n, q$ on the first line.

$n$ lines, each containing two integers $a_i, b_i$.

$q$ lines, each representing an operation as described above.

Output

For each query operation, output one integer per line.

Constraints

$1 \le n, q \le 1 \times 10^5, 1 \le a_i < b_i \le 10^9, 0 \le l \le r < n, 1 \le k \le 2(r - l + 1)$

Subtasks

Subtask ID Special Properties Score
1 $1 \le n, q \le 14$ 5
2 $1 \le n, q \le 300$ 5
3 $1 \le n, q \le 2 \times 10^3$ 15
4 $1 \le n, q \le 1 \times 10^5, l = 0$, no type 1 operations 15
5 No type 1 operations 10
6 $1 \le n, q \le 8 \times 10^4$ 20
7 None 30

Examples

Input 1

3 3
1 10
2 10
3 10
2 0 2 3
1 1 5 6
2 0 2 3

Output 1

6
7

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

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.