Pădurar

Time limit: 0.05s Memory limit: 2MB Input: padurar.in Output: padurar.out

Task

Nicholas works at a sawmill and needs to prepare a package of exactly KK identical planks, each having length LL. The warehouse contains NN logs with lengths H1,H2,,HNH_1, H_2, \dots, H_N.

Nicholas can cut several planks of length LL from a single log, but each cut wears out his saw. He has established the following rules:

  1. One or more planks of length LL can be cut from any log. Any piece of wood remaining that is shorter than LL is considered waste.
  2. Each cut consumes 1 unit of the saw's total durability XX.
    • Example: If a log has length 1010 and planks of length 55 are needed, one single cut is made in the middle to obtain 22 planks (cost 11 unit).
    • Example: If a log has length 1212 and planks of length 55 are needed, two cuts are made (at distance 55 and 1010) to obtain 22 planks, the remaining 22 being waste (cost 22 units).

Help Nicholas find the maximum length LL that the KK planks can have, without exceeding the saw's durability XX.

Input Data

The first line contains three integers N,KN, K, and XX.
The second line contains NN integers representing the log lengths H1,H2,,HNH_1, H_2, \dots, H_N.

Output Data

Print a single natural number representing the maximum length LL. If it is impossible to obtain KK planks, print 00.

Constraints and Clarifications

  • 1N100,0001 \leq N \leq 100,000
  • 1K,X1091 \leq K, X \leq 10^9
  • 1Hi1091 \leq H_i \leq 10^9
  • For 20% of the score: N,K,Hi100N, K, H_i \leq 100
  • For another 30% of the score: N1,000,Hi106N \leq 1,000, H_i \leq 10^6

Example

padurar.in

2 4 3
10 12

padurar.out

5

Explanation

For L=5L=5:

  • From the first log (1010), 22 planks are obtained using 11 cut.
  • From the second log (1212), 22 planks are obtained using 22 cuts.
    Total: 44 planks and 33 cuts. The conditions are met.
    If we chose L=6L=6, we would obtain only 1+1=21 + 1 = 2 planks, so L=5L=5 is the maximum.

Log in or sign up to be able to send submissions!