QOJ.ac

QOJ

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

#9336. 两个杀手

الإحصائيات

在著名的波兰电影《Two Kilers》中,主角 Jurek Kiler 定期会收到装有金币的箱子。每次交付都可以用其中金箱子的价值来描述,第 $i$ 次交付的价值等于 $c_i$。

最近,Jurek 开始担心交付的价值正在下降。为了检查这些价值是否真的在下降,他发明了一种衡量交付序列的方法,他称之为序列的混乱度(disorder)。

对于整数序列 $c_1, c_2, \dots, c_n$,该序列的混乱度等于其最长严格上升子序列的长度。形式化地,它是满足 $c_{i_1} < c_{i_2} < \dots < c_{i_s}$ 的最大整数 $s$,其中索引满足 $i_1 < i_2 < \dots < i_s$。

Jurek 认为,如果序列的混乱度至少为 $k$,那么他的担忧就是多余的——此时他对混乱度的精确值并不感兴趣。问题在于,交付中的一些金箱子经常被盗,或者有时少数金箱子会延迟很久才送达,因此交付的价值可能会发生变化。你的任务是在每次修改后计算混乱度的值,如果混乱度至少为 $k$,则输出 $k$。

输入格式

第一行包含一个整数 $Z \le 10$,表示接下来描述的测试用例数量。

对于每个测试用例:

第一行包含两个整数 $n, k$,分别表示交付的数量和参数 $k$ 的值。

第二行包含 $n$ 个整数 $c_1, c_2, \dots, c_n$,表示交付的初始价值。

第三行包含一个整数 $q$,表示交付价值发生变化的次数。

接下来的 $q$ 行,每行包含两个整数 $p_j, v_j$,表示将 $c_{p_j}$ 修改为 $v_j$。

输出格式

对于每个测试用例,输出 $q$ 行,每行包含一个自然数。如果第 $j$ 次修改后的混乱度为 $s$,则在第 $j$ 行输出 $\min(s, k)$。

数据范围

  • $n, q \in [1, 10^5]$
  • $c_i, v_j \in [1, 10^9]$
  • $p_j \in [1, n]$
  • $k \in [1, 20]$

样例

输入 1

2
3 3
1 1 1
2
3 3
2 2
5 3
1 2 3 4 5
4
1 5
4 2
2 4
5 1

输出 1

2
3
3
3
2
1

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.