PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000277. San bằng ngọn núi trong thời gian ít nhất (Minimum Number of Seconds to Make Mountain Height Zero)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
San bằng ngọn núi trong thời gian ít nhất (Minimum Number of Seconds to Make Mountain Height Zero)
Minimum Number of Seconds to Make Mountain Height Zero
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
A mountain has height . There are workers operating concurrently. Worker i needs seconds for the j-th unit of height they remove, so removing k units costs . Assign exactly H units to minimize the maximum individual completion time.
Input
First line: . Second line: integers .
Output
Print the minimum number of seconds.
Subtasks
- Subtask 1 (20 points): ; ; ().
- Subtask 2 (30 points): ; ; (); .
- Subtask 3 (50 points): ; ; ().
Examples
Input 1
4 3
2 1 1
Output 1
3
Explanation
Assign 1,2,1 units, taking 2,3,1 seconds. Within two seconds each can remove only one unit.