#P14115. [IAMOI R4] 木桶效应

    ID: 13547 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>贪心二分洛谷原创O2优化洛谷月赛

[IAMOI R4] 木桶效应

Description

T has a bucket made of nn vertical wooden planks. The height of the ii-th plank is aia_i. To increase the bucket's water-holding capacity, she plans to install some additional planks.

T has two types of planks available: mm planks of height 11, and kk planks of height hh. Each of these planks can be installed on top of one of the bucket's original planks. Multiple planks can be stacked on a single original plank. After installation, an original plank and all planks added on top of it are considered a single plank, and its new height is the sum of their individual heights.

Since the water-holding capacity is determined by the shortest plank, T wants to know what is the maximum possible height of the shortest plank after adding the new planks.

Input Format

The first line contains four integers: n,m,k,hn, m, k, h.

The second line contains nn positive integers a1,,ana_1, \dots, a_n, representing the initial heights of the planks.

Output Format

Output a single line containing a positive integer, which is the answer.

3 5 1 3
2 5 4
6
4 10 2 5
10 11 12 13
16
5 10 0 100
1 2 3 4 5
5

Hint

【Sample 1 Explanation】

We can add 4 planks of height 1 to the first original plank, 1 plank of height 1 to the second original plank, and 1 plank of height 3 to the third original plank. The heights of the three planks then become 6,6,76, 6, 7. The height of the shortest plank is 66.

【Data Constraints】

Subtask # nn\le mm\le kk\le hh\le Special Property
11 1010 33 10910^9 None
22 ^ ^ 10310^3 ^ ^
33 10310^3 33
44 10510^5 00 10510^5
55 ^ 10510^5 00
686\sim 8 ^ 10510^5
9,109,10 00 10910^9
11,1211,12 10910^9 00
13,1413,14 ^ 10910^9 22
15,1615,16 ^ 10910^9 Yes
172017\sim 20 ^ None
  • Special Property: a1=a2==ana_1=a_2=\dots=a_n.

For all test cases, it is guaranteed that: 1n1051\le n\le 10^5, 0m,k1090\le m,k\le 10^9, 1ai1091\le a_i\le 10^9, 2h1092\le h\le 10^9.