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
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
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 buss, numbered 1 through . At least trips must be completed. Bus takes 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 , the number of buss and required trips.
The second line contains integers , the processing times of the buss.
Output
Print the minimum time as one integer.
Subtasks
- Subtask 1 (20 points): ; ; for every .
- Subtask 2 (30 points): ; ; for every . .
- Subtask 3 (50 points): ; ; for every .
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.