3099: Fighting Against Involution

时间限制:1000 ms 内存限制:128 MB
上传者:
提交:40 通过:16

题目描述

As is known to everyone, score is very important to college student. So, every student will write words as many as possible to earn more score in the course final paper. The teacher will give student score depend on the rank of his word number in all students.

Let $w_i$ denote the word count of the $i$-th student's plan to write in final papper. To pass the coures, obviously, every student will write at least $L$ word, and to avoid being exhausted, they will not write over $R$ word. It means that $L \le w_i \le R$.

Caring classmates physical and mental heathy, Dr.GreenPepper ask everyone's plan, then he could tell everyone how many words they acctually need to write. That result will let sum of $w_i$ will be minimize. For each student, his rank won't change.

You need help Dr.GreenPepper to calculate the minimum value of $\sum^n_{i=1} w_i$

输入格式

First line contains an integer $T(1\le T \le 10)$, which indicates the number of test cases.

Each test case contains three integers $n$, $L$, $R~(1\le n \le 10^3, 1\le L \le w_i \le R \le 10^9)$ indicating the number of student, the lower bound of the words, the upper bound of words.

The next lines contains $n$ integers. The $i$-th integer indicating the $i$-th student's plan of words.

输出格式

Output the minimum value of $\sum^n_{i=1} w_i$.

输入样例 复制

1
10 10 20
11
13
12
19
20
14 
14
10
15
16 

输出样例 复制

140