QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 512 MB Total points: 100

#1611. 加法

統計

可怜有一个长度为 $n$ 的正整数序列 $A$ ,但是她觉得 $A$ 中的数字太小了,这让她很不开心。
于是她选择了 $m$ 个区间 $[l_i , r_i]$ 和两个正整数 $a$ , $k$ 。她打算从这 $m$ 个区间里选出恰好 $k$ 个区间,并对每个区间执行一次区间加 $a$ 的操作。 (每个区间最多只能选择一次。)

对区间 $[l, r]$ 进行一次加 $a$ 操作可以定义为对于所有 $i \in [l, r]$ ,将 $A_i$ 变成 $A_i + a$ 。
现在可怜想要知道怎么选择区间才能让操作后的序列的最小值尽可能的大,即最大化 $ \min \{ A_i \} $ 。

输入格式

第一行输入一个整数表示数据组数。

对于每组数据第一行输入四个整数 $n,m,k,a$ 。

第二行输入 $n$ 个整数描述序列 $A$ 。

接下来 $m$ 行每行两个整数 $l_i,r_i$ 描述每一个区间。数据保证所有区间两两不同。

输出格式

对于每组数据输出一个整数表示操作后序列最小值的最大值。

样例数据

样例输入

1
3 3 2 1
1 3 2
1 1
1 3
3 3

样例输出

3

样例解释

选择给区间 $[1, 1]$ 和 $[1, 3]$ 加 $1$ 。

子任务

测试点编号 $\sum n$ $\sum m$
$1$ $\leq 20$ $\leq 20$
$2$ $\leq 20$ $\leq 20$
$3$ $\leq 2000$ $\leq 2000$
$4$ $\leq 2000$ $\leq 2000$
$5$ $\leq 2000$ $\leq 2000$
$6$ $\leq 2000$ $\leq 2000$
$7$ $\leq 2 \times 10^5$ $\leq 2 \times 10^5$
$8$ $\leq 2 \times 10^5$ $\leq 2 \times 10^5$
$9$ $\leq 2 \times 10^5$ $\leq 2 \times 10^5$
$10$ $\leq 2 \times 10^5$ $\leq 2 \times 10^5$
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.