#include<bits/stdc++.h> using namespace std; typedef long long ll; #define endl "\n" int main() { ios::sync_with_stdio(false), cin.tie(0), cout.tie(0); int T = 1; cin >> T; while (T--) { ll n1, c, d; cin >> n1 >> c >> d; ll ans = 0; vector<ll>vec; map<ll, int>mp; for (int i = 1; i <= n1; i++) { ll x; cin >> x; if (!mp[x]) { vec.push_back(x); mp[x] = 1; } else ans += c; } sort(vec.begin(), vec.end()); int n = vec.size(); ll maxn = vec[n - 1]; ll ans1 = LLONG_MAX; for (int i = 0; i < n; i++) { ll res = (vec[i] - 1 - i) * d + (n - i - 1) * c; ans1 = min(ans1, res); } ll ans2 = n1 * c + d; if (mp[1])ans2 = (n1 - 1) * c; cout << min(ans1+ans,ans2) << endl; } return 0; }
标签:Rated,int,ans1,Make,vec,n1,Div,ll From: https://www.cnblogs.com/zhujio/p/17281069.html