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

#BS0000286. Cắt dây ruy băng (Cutting Ribbons)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Cắt dây ruy băng (Cutting Ribbons)

Cutting Ribbons

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn ribbons of integer lengths aia_i. Each ribbon may remain intact or be cut into positive integer lengths. Joining pieces is forbidden. Select exactly kk pieces of equal length, discarding leftovers if desired. Find their maximum positive integer length, or 00 if impossible.

Input

First line: n,kn,k. Second line: nn integers aia_i.

Output

Print the maximum value, or 00.

Subtasks

  • Subtask 1 (20 points): 1≤n≤301\le n\le30; 1≤ai≤1001\le a_i\le100; 1≤k≤10001\le k\le1000.
  • Subtask 2 (30 points): 1≤n≤1051\le n\le10^5; 1≤ai≤1051\le a_i\le10^5; a1=⋯=ana_1=\cdots=a_n; 1≤k≤1091\le k\le10^9.
  • Subtask 3 (50 points): 1≤n≤1051\le n\le10^5; 1≤ai≤1051\le a_i\le10^5; 1≤k≤1091\le k\le10^9.

Examples

Input 1

3 4
7 5 9

Output 1

4

Explanation

Lengths 7, 5, 9 yield 1, 1, 2 pieces of length 4; length 5 yields only three pieces.

Input 2

2 11
2 5

Output 2

0

Explanation

The total is 7, so 11 positive groups are impossible.