#include #include #include #include #define rep(i,n) for(i=0;i<(int)(n);i++) #define MAX_H (int)(1e9) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair P; int n,a,b,x,y; int main(){ int i,j,left,right,mid; scanf("%d%d%d%d%d",&n,&a,&b,&x,&y); vector h(n); rep(i,n)scanf("%d",&h[i]); auto judge=[&](int k,vector h)->bool{ int i,aa=a; rep(i,n)h[i]-=k; priority_queue

PQ; P now; //Magic A rep(i,n)PQ.push(P(h[i],i)); while(PQ.size()&&aa>0){ now=PQ.top();PQ.pop(); if(now.first<=0)break; now.first-=x; h[now.second]-=x; if(now.first>0)PQ.push(now); aa--; } //Magic B ll p=(ll)y*b,d; rep(i,n){ if(h[i]>0){ h[i]-=(d=min(p,(ll)h[i])); p-=d; if(h[i]>0)return false; } } return true; }; left=0;right=MAX_H+1; while(left