#include "atcoder/all" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; const long long int INF = numeric_limits::max() / 4; const int inf = numeric_limits::max() / 4; const long long int MOD1000000007 = 1000000007; const long long int MOD998244353 = 998244353; const double MATH_PI = 3.1415926535897932; template inline void chmin(T1 &a, const T2 &b) { if (a > b) a = b; } template inline void chmax(T1 &a, const T2 &b) { if (a < b) a = b; } #define lint long long int #define ALL(a) a.begin(),a.end() #define RALL(a) a.rbegin(),a.rend() #define rep(i, n) for(int i=0;i<(int)(n);i++) #define VI vector #define VLL vector #define VC vector #define VB vector #define PI pair #define PLL pair #define VPI vector> #define VPLL vector> #define VVI vector> #define VVPI vecor>> #define VVPILL vector>> #define SUM(v) accumulate(ALL(v), 0LL) #define MIN(v) *min_element(ALL(v)) #define MAX(v) *max_element(ALL(v)) bool solve(vector h, lint a, lint b, lint x, lint y) { // 体力 x 減らすを a 回使える int n = h.size(); for (int i = 0; i < n; i++) { if (a <= 0) break; lint cnt = h[i] / x; if (cnt > a) { cnt = a; } h[i] -= cnt * x; a -= cnt; } sort(RALL(h)); // a が許す限り 0 にする for (int i = 0; i < n; i++) { if (a <= 0) break; h[i] = 0; a--; } // 総和が b * y よりでかいかどうか return SUM(h) <= b * y; } int main() { lint n, a, b, x, y; cin >> n >> a >> b >> x >> y; vector h(n); rep (i, n) cin >> h[i]; if (solve(h, a, b, x, y)) { cout << 0 << endl; return 0; } lint ng = 0; lint ok = 1e9; while (ok - ng > 1) { lint k = (ok + ng) / 2; vector tmp(n); rep (i, n) { tmp[i] = max(h[i] - k, 0LL); } if (solve(tmp, a, b, x, y)) { ok = k; } else { ng = k; } } cout << ok << endl; return 0; }