/* -*- coding: utf-8 -*- * * 1071.cc: No.1071 ベホマラー - yukicoder */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; /* constant */ const int MAX_N = 100000; const long long LINF = 1LL << 62; /* typedef */ typedef long long ll; /* global variables */ int cs[MAX_N]; ll css[MAX_N + 1]; /* subroutines */ /* main */ int main() { int n, k, x, y; scanf("%d%d%d%d", &n, &k, &x, &y); for (int i = 0; i < n; i++) { int ai; scanf("%d", &ai); cs[i] = ((ai - 1) + (k - 1)) / k; } sort(cs, cs + n); for (int i = 0; i < n; i++) css[i + 1] = css[i] + cs[i]; ll minp = LINF; for (int i = n; i >= 0; i--) { int ci = (i > 0) ? cs[i - 1] : 0; ll p = (ll)ci * y + ((css[n] - css[i]) - (ll)ci * (n - i)) * x; if (minp <= p) break; minp = p; } printf("%lld\n", minp); return 0; }