PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#BS0000273. Tìm số chia nhỏ nhất (Find the Smallest Divisor Given a Threshold)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tìm số chia nhỏ nhất (Find the Smallest Divisor Given a Threshold)

Find the Smallest Divisor Given a Threshold

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

Given positive integers a1,…,ana_1,\ldots,a_n and a threshold TT, choose a positive integer dd to minimize dd subject to ∑i=1n⌈ai/d⌉≤T\sum_{i=1}^n\lceil a_i/d\rceil\le T. The ceiling rounds upward to an integer. An answer is guaranteed.

Input

The first line contains n,Tn,T. The next line contains nn values aia_i.

Output

Print the smallest divisor.

Subtasks

  • Subtask 1 (20 points): 1≤n≤101\le n\le10; 1≤ai≤501\le a_i\le50; n≤T≤100n\le T\le100 (1≤i≤n1\le i\le n).
  • Subtask 2 (30 points): 1≤n≤5⋅1041\le n\le5\cdot10^4; 1≤ai≤1061\le a_i\le10^6 (1≤i≤n1\le i\le n); T=nT=n.
  • Subtask 3 (50 points): 1≤n≤5⋅1041\le n\le5\cdot10^4; 1≤ai≤1061\le a_i\le10^6 (1≤i≤n1\le i\le n); n≤T≤106n\le T\le10^6.

Examples

Input 1

4 6
1 2 5 9

Output 1

5

Explanation

At d=4 the sum is 7, at d=5 it is 5. Monotonicity implies 5 is minimal.