QOJ.ac

QOJ

実行時間制限: 3 s メモリ制限: 2048 MB 満点: 100

#7847. 数字中的历史

統計

算法和数据结构在各种艺术、工艺和科学领域中都有其用武之地。在本题中,我们将讨论其在历史学中的一个潜在应用。

历史学家正在研究某城市在 $n$ 年期间的城市发展情况。城市发展通过一个他们称为城市发展指数(UDI)的综合指标来量化,该指标可以取整数值,包括负数。对于每一年,都有该指数的初始估计值 $e_i$。然而,在研究过程中,由于发现了新的文档和证据,这些估计值会被修订和更新。更正式地说,在历史学家的工作过程中,他们可能希望通过给第 $s_j$ 年到第 $f_j$ 年(包含首尾)的所有年份的 UDI 估计值加上 $d_j$ 来进行更新。

历史学家最关心的问题是 UDI 在某一段时间内是否一直在增长。然而,由于估计值具有噪声,我们不会使用标准定义。相反,我们使用以下过程:

  • 我们将所有连续相等的数字合并为一个。例如,1 1 2 2 2 3 3 3 变为 1 2 3;
  • 如果 UDI 序列经过上述变换后的局部极小值序列是严格递增的,则认为 UDI 从第 $i$ 年到第 $j$ 年是增长的。如果一个元素 $p_i$ 小于它的所有邻居(对于第一个或最后一个元素,只有一个邻居),则认为它是局部极小值。

你需要实现一个系统,能够存储 UDI 估计值,处理更新请求,并检查 UDI 在某一段时间内是否一直在增长。

输入格式

  • 第一行包含一个整数 $n$ ($1 \le n \le 3 \cdot 10^5$),表示所考虑的时间段长度。
  • 第二行包含 $n$ 个空格分隔的整数 $e_i$ ($-10^8 \le e_i \le 10^8$)。
  • 第三行包含一个整数 $m$ ($1 \le m \le 3 \cdot 10^5$)。
  • 接下来 $m$ 行,每行描述一个请求,格式为以下两种之一:
    • update 后跟三个整数 $s_j$、$f_j$ 和 $d_j$ ($1 \le s_j \le f_j \le n$, $|d_j| \le 10^8$)。
    • check 后跟两个整数 $s$ 和 $f$ ($1 \le s \le f \le n$)。

输出格式

对于每个 check 请求,如果 UDI 在相应期间内一直在增长,则输出 YES,否则输出 NO

样例

输入格式 1

5
10 4 10 6 10
5
check 1 5
update 2 3 1
check 1 5
update 2 3 1
check 1 5

输出格式 1

YES
YES
NO

输入格式 2

8
10 -5 -5 -5 11 6 6 12
1
check 1 8

输出格式 2

YES

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.