# region template import sys import typing from typing import Callable, Dict, List, Set, Tuple import heapq from operator import itemgetter sys.setrecursionlimit(10 ** 6) Vec = List[int] VecVec = List[Vec] sinput: Callable[..., str] = sys.stdin.readline MOD: int = 1000000007 INF: float = float("Inf") IINF: int = sys.maxsize # endregion def meguru_bisect(ok: int, ng: int, is_ok: Callable[..., bool], *args) -> int: """二分探索法 Args: ok (int): is_okを満たす初期値 ng (int): is_okを満たさない初期値 is_ok (typing.Callable[..., bool]): 判定用関数 *args (object): is_okに渡される引数 Returns: int: is_okを満たす最大/小の整数 """ assert is_ok(ok, *args) assert not is_ok(ng, *args) while abs(ok - ng) > 1: mid = (ok + ng) >> 1 if is_ok(mid, *args): ok = mid else: ng = mid return ok def main() -> None: n, a, b, x, y = map(int, sinput().split()) h = tuple(map(int, sinput().split())) def ok(th: int) -> bool: if th < 0: return False rem_b = y * b que = [(-h[i] + th, i) for i in range(n)] heapq.heapify(que) for _ in range(a): top, i = heapq.heappop(que) top += x heapq.heappush(que, (top, i)) que.sort(key=itemgetter(1)) for hi, _ in que: hi *= -1 if hi >= 0: if hi > rem_b: return False else: rem_b -= hi return True print(meguru_bisect(max(h), -1, ok)) if __name__ == "__main__": main()