QOJ.ac

QOJ

時間限制: 5 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#11514. 高效数据结构

统计

Elly 有两个序列 $a_1, a_2, \dots, a_n$ 和 $b_1, b_2, \dots, b_n$。她想要执行以下操作:

  • $1 \ x \ y$,将 $a_x$ 的值修改为 $y$。
  • $2 \ x \ y$,将 $b_x$ 的值修改为 $y$。
  • $3 \ x$,求 $c_x$ 的值,其中 $c_0 = 0$,$c_i = \max(c_{i-1} + b_i, a_i)$,对于 $1 \le i \le x$。

请实现一个高效的数据结构来处理这些操作。

输入格式

输入包含多组测试数据,以文件结束符(EOF)结束。对于每组测试数据:

第一行包含两个整数 $n$ 和 $m$,分别表示两个序列的长度和操作次数。 第二行包含 $n$ 个整数 $a_1, a_2, \dots, a_n$。 第三行包含 $n$ 个整数 $b_1, b_2, \dots, b_n$。 接下来的 $m$ 行,每行包含一个操作。

  • $1 \le n, m \le 2 \times 10^5$
  • $-10^9 \le a_i, b_i, y \le 10^9$
  • $1 \le x \le n$
  • $n$ 的总和与 $m$ 的总和均不超过 $2 \times 10^6$。

输出格式

对于每个类型为 3 的操作,输出一个整数,表示 $c_x$ 的值。

样例

样例输入 1

4 9
1 2 3 3
-1 2 3 3
3 1
3 2
3 3
3 4
2 2 -4
3 1
3 2
3 3
3 4

样例输出 1

1
3
6
9
1
2
5
8

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.