Codeforces Round 1000 (Div. 2)
B
Subsequence Update
Codeforces
1100
原题
← AC →
翻译中…

After Little John borrowed expansion screws from auntie a few hundred times, eventually she decided to come and take back the unused ones.But as they are a crucial part of home design, Little John decides to hide some in the most unreachable places — under the eco-friendly wood veneers.

翻译中…

You are given an integer sequence $a_1, a_2, \ldots, a_n$, and a segment $[l,r]$ ($1 \le l \le r \le n$).

翻译中…

You must perform the following operation on the sequence exactly once.

翻译中…
  • Choose any subsequence$^{\text{∗}}$ of the sequence $a$, and reverse it. Note that the subsequence does not have to be contiguous.
翻译中…

Formally, choose any number of indices $i_1,i_2,\ldots,i_k$ such that $1 \le i_1 \lt i_2 \lt \ldots \lt i_k \le n$. Then, change the $i_x$-th element to the original value of the $i_{k-x+1}$-th element simultaneously for all $1 \le x \le k$.

翻译中…

Find the minimum value of $a_l+a_{l+1}+\ldots+a_{r-1}+a_r$ after performing the operation.

翻译中…

$^{\text{∗}}$A sequence $b$ is a subsequence of a sequence $a$ if $b$ can be obtained from $a$ by the deletion of several (possibly, zero or all) element from arbitrary positions.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $l$, $r$ ($1 \le l \le r \le n \le 10^5$) — the length of $a$, and the segment $[l,r]$.

翻译中…

The second line of each test case contains $n$ integers $a_1,a_2,\ldots,a_n$ ($1 \le a_{i} \le 10^9$).

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.

翻译中…

Output

翻译中…

For each test case, output the minimum value of $a_l+a_{l+1}+\ldots+a_{r-1}+a_r$ on a separate line.

翻译中…

Note

翻译中…

On the second test case, the array is $a=[1,2,3]$ and the segment is $[2,3]$.

翻译中…

After choosing the subsequence $a_1,a_3$ and reversing it, the sequence becomes $[3,2,1]$. Then, the sum $a_2+a_3$ becomes $3$. It can be shown that the minimum possible value of the sum is $3$.

翻译中…

样例

Input #1
6
2 1 1
2 1
3 2 3
1 2 3
3 1 3
3 1 2
4 2 3
1 2 2 2
5 2 5
3 3 2 3 5
6 1 3
3 6 6 4 3 2
Output #1
1
3
6
3
11
8
InputCopy OutputCopy
题目信息
题号
2063B
时间限制
1.5 s
内存限制
256 MB
标签
构造
数据结构
贪心
排序

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。