#P14115. [IAMOI R4] 木桶效应
[IAMOI R4] 木桶效应
Description
T has a bucket made of vertical wooden planks. The height of the -th plank is . To increase the bucket's water-holding capacity, she plans to install some additional planks.
T has two types of planks available: planks of height , and planks of height . 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: .
The second line contains positive integers , 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 . The height of the shortest plank is .
【Data Constraints】
| Subtask # | Special Property | ||||
|---|---|---|---|---|---|
| None | |||||
| ^ | ^ | ^ | ^ | ||
| ^ | |||||
| ^ | |||||
| ^ | |||||
| ^ | Yes | ||||
| ^ | None | ||||
- Special Property: .
For all test cases, it is guaranteed that: , , , .
京公网安备 11011102002149号