#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define len(s) s.size()
#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define vi vector<int>
#define mii map<int, int>
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define nl '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define dbg(x) cout << #x << " " << x << nl
#define mod 1000000007
#define md 998244353
#define ld long double
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define arrayin(a, n) \
int a[n]; \
for (int i = 0; i < n; i++) \
cin >> a[i]
void Print(int32_t x)
{
cout << x << " ";
}
void Print(char x) { cout << x << " "; }
void Print(double x) { cout << x << " "; }
void Print(int64_t x) { cout << x << " "; }
void print() { cout << endl; }
void Print(bool x) { cout << (x ? "YES" : "NO"); }
void Print(string x) { cout << x << " "; }
template <typename T, typename V>
void Print(const pair<T, V> x)
{
cout << x.first << " " << x.second << endl;
}
template <typename T>
void Print(const T &x)
{
for (auto &i : x)
Print(i);
}
template <typename T, typename... V>
void print(T t, V... v)
{
Print(t);
print(v...);
}
ll gcd(ll a, ll b)
{
if (b == 0)
return a;
if (b == 1)
return 1;
else
return gcd(b, a % b);
}
vector<char> vwl = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'};
bool vowel(char a)
{
for (auto x : vwl)
if (a == x)
return true;
return false;
}
ll root(ll x)
{
ll ans;
if (x == 1)
return 1;
ll s = 1, e = INT_MAX / 2, mid;
while (s <= e)
{
mid = (s + e) >> 1;
if (mid * mid <= x)
{
ans = mid;
s = mid + 1;
}
else
e = mid - 1;
}
return ans;
}
bool isPrime(ll x)
{
if (x == 1)
return 0;
for (ll i = 2; i * i <= x; i++)
{
if (x % i == 0)
return false;
}
return true;
}
ll power(ll a, ll b)
{
if (a <= 0 || b < 0)
return 0;
if (b == 0)
return 1;
if (b % 2)
return (a * power(a, b - 1));
else
return power((a * a), b / 2);
}
int sod(int x)
{
int ans = 0;
while (x)
{
ans += x % 10;
x /= 10;
}
return ans;
}
int nod(int x)
{
int ans = 0;
while (x)
{
ans++;
x /= 10;
}
return ans;
}
ll mod_power(ll a, ll b)
{
if (b == 0)
return 1;
if (b == 1)
return a;
if (b % 2)
return (a % mod * mod_power(a, b - 1) % mod) % mod;
else
return mod_power((a % mod * a % mod) % mod, b / 2) % mod;
}
ll max(ll a, ll b)
{
return a > b ? a : b;
}
ll min(ll a, ll b)
{
return a < b ? a : b;
}
bool multitest = 1;
void solve()
{
int n,c,d;
cin>>n>>c>>d;
arrayin(a,n);
sort(a,a+n);
ordered_set s;
for(int i =0;i<n;i++){
s.insert(a[i]);
}
int ans = 1e18;
for(int i = 1;i<=n;i++){
int x = s.order_of_key(i+1);
ans = min(ans,(n-x)*c+max(0,i-x)*d);
}
for(int i = 0;i<n;i++){
int x = s.order_of_key(a[i]+1);
ans = min(ans,(n-x)*c+max(0,a[i]-x)*d);
}
cout<<ans<<nl;
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tc = 1;
if (multitest)
cin >> tc;
for (int tt = 1; tt <= tc; tt++)
{
solve();
}
}
1574C - Slay the Dragon | 621A - Wet Shark and Odd and Even |
1395A - Boboniu Likes to Color Balls | 1637C - Andrew and Stones |
1334B - Middle Class | 260C - Balls and Boxes |
1554A - Cherry | 11B - Jumping Jack |
716A - Crazy Computer | 644A - Parliament of Berland |
1657C - Bracket Sequence Deletion | 1657B - XY Sequence |
1009A - Game Shopping | 1657A - Integer Moves |
230B - T-primes | 630A - Again Twenty Five |
1234D - Distinct Characters Queries | 1183A - Nearest Interesting Number |
1009E - Intercity Travelling | 1637B - MEX and Array |
224A - Parallelepiped | 964A - Splits |
1615A - Closing The Gap | 4C - Registration System |
1321A - Contest for Robots | 1451A - Subtract or Divide |
1B - Spreadsheet | 1177A - Digits Sequence (Easy Edition) |
1579A - Casimir's String Solitaire | 287B - Pipeline |