PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000335. Tối đa hóa điện năng thấp nhất (Maximize the Minimum Powered City)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Tối đa hóa điện năng thấp nhất (Maximize the Minimum Powered City)
Maximize the Minimum Powered City
Source: LeetCode
Version: Phuoc Hung OJ Extended
Problem Statement
There are cities indexed from 0 to along a line, with stations at city i. A station at i contributes one unit of power to each city j satisfying . Build exactly additional stations at any cities, possibly repeatedly at the same city. Maximize the minimum power among all cities.
Input
First line: . Second line: integers .
Output
Print the largest achievable minimum power.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples
Input 1
5 1 2
1 2 4 5 0
Output 1
5
Explanation
Build both stations in city 1, obtaining powers 5,9,13,9,5. To reach 6 the two disjoint end regions would need at least 3 and 1 additional stations.
Input 2
4 0 3
4 4 4 4
Output 2
4
Explanation
Four additional stations would be needed to reach power 5 everywhere.