给定长度为n的一段数,通过两中操作将这段数变成排列,也就是这段数中只含有1~n,这个n可以不是原来的n
操作1 :删除一个数,花费c
操作2:在任意位置加上一个任意的数,花费d
要求花费最小,输出这个花费
输入
8
3 3 3
1 2 3
5 1 5
1 2 3 5 6
5 2 3
1 1 1 3 3
5 1 10
2 4 6 8 10
6 2 8
7 3 5 4 4 8
4 10 1
1 2 6 7
4 3 3
2 5 8 7
2 1000000000 1
1000000000 1
输出
0
2
8
14
20
3
12
999999998
#include <iostream>
#include <bits/stdc++.h>
#include <cstring>
#include <vector>
#include <unordered_map>
#include <queue>
#include <set>
//#define int long long
#include <algorithm>
#define x first
#define y second
#define pb emplace_back
#define fu(i,a,b) for(int i=a;i<=b; ++ i)
#define fd(i,a,b) for(int i=a;i>=b; -- i)
#define endl '\n'
#define ms(x,y) memset(x,y,sizeof x)
#define ios ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<vector<LL>> VVL;
typedef vector<vector<int>> VVI;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef pair<PII,int> PIII;
typedef pair<double,double> PDD;
typedef pair<double,int> PDI;
typedef pair<char,int> PCI;
typedef pair<string,int> PSI;
typedef pair<int,string> PIS;
typedef pair<int,char> PIC;
typedef pair<LL,LL> PLL;
typedef __int128 i128;
typedef unsigned long long ULL;
const int N =1e3+ 10,M = N *40,INF = 0x3f3f3f3f,P = 131;
const double eps = 1e-8;
const int mod = 998244353,base= 20010;
const LL LNF=(LL) INF * INF;
inline void solve()
{
int n,c,d;cin >> n >> c >> d;
VI a(n);
fu(i,0,n-1)
{
cin >> a[i];
}
sort(a.begin(),a.end());
LL ans=(LL)c * n + d ; // 全部数删掉 加个1
int t =0 ;
fu(i,0,n-1)
{
if(i == 0 || a[i] != a[i-1]) // 第一个数 或 不是重复的数
t ++ ; // 正确的数 的长度
ans = min(ans,(LL) c * n + (LL)d * a[i] - (LL)(c+d) * t );
// 全部删除 ,加入 a[i]个 数, 前a[i]个数中 处在正确位置上的数不用进行前面的两个操作
// a[i] >= i ,t<= i === a[i] >= t
// d * a[i] - (c+d) *t === d*(a[i] - t ) - c * t
}
cout<< ans << endl;
}
signed main()
{
// freopen("1.txt","r",stdin);
// #define int long long
// init(N-1);
ios
// cout << fixed<<setprecision(2);
int t=1;
cin>>t;
int now = 1;
while(t -- )
{
// cout<<"Case ";
// cout<<"Case #";
// cout<<"Scenario #";
// cout<< now ++ <<": ";
// cout<< now ++ <<": \n";
solve();
}
return 0;
}