#include using namespace std; int main() { int N,X,Y,a,b; cin >> N >> a >> b >> X >> Y; vectorH(N); for(int i = 0; i < N; i++) { cin >> H[i]; } int l = 0,r = 1001001001; while (l+1 < r) { int mid = (l+r)/2; int p = 0; int A = a,B = b; priority_queueque; for(int i = 0; i < N; i++) { if(H[i] > mid) { que.push(H[i]-mid); } } while (!que.empty() && (A || B || p)) { int x = que.top(); que.pop(); if(A) { A--; x = max(0,x-X); if(x) { que.push(x); } } else { if(p == 0) { p = Y; B--; } int D = min(p,x); x -= D; p -= D; if(x) { que.push(x); } } } if(que.empty()) { r = mid; } else { l = mid; } } cout << r << endl; }