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

#BS0000249. Thời gian hoàn thành các chuyến đi (Minimum Time to Complete Trips)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Thời gian hoàn thành các chuyến đi (Minimum Time to Complete Trips)

Minimum Time to Complete Trips

Source: LeetCode

Version: Phuoc Hung OJ Extended

Problem Statement

There are nn buss, numbered 1 through nn. At least tt trips must be completed. Bus ii takes aia_i time units per trip and can start the next one immediately after finishing the previous one. All buss can work independently and simultaneously from time zero. Find the minimum time required.

Input

The first line contains integers n,tn,t, the number of buss and required trips.

The second line contains nn integers a1,a2,…,ana_1,a_2,\ldots,a_n, the processing times of the buss.

Output

Print the minimum time as one integer.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1001\le n\le 100; 1≤t≤10001\le t\le 1000; 1≤ai≤100000001\le a_i\le 10000000 for every 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤1000001\le n\le 100000; 1≤t≤100000001\le t\le 10000000; 1≤ai≤100000001\le a_i\le 10000000 for every 1≤i≤n1\le i\le n. a1=a2=⋯=ana_1=a_2=\cdots=a_n.
  • Subtask 3 (50 points): 1≤n≤1000001\le n\le 100000; 1≤t≤100000001\le t\le 10000000; 1≤ai≤100000001\le a_i\le 10000000 for every 1≤i≤n1\le i\le n.

Examples

Input

3 5
1 2 3

Output

3

Explanation

At time 2 the buses complete 2, 1, and 0 trips, totaling 3. At time 3 they complete 3, 1, and 1, totaling 5. The answer is 3.