The Enlightened Ones
Practice
4.2 (164 votes)
Approved
Binary search
Medium
Open
Sorting
Problem
81% Success 4373 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

There are N temples in a straight line and K monks who want to spread their enlightening power to the entire road of temples. All the monks have an enlightenment value, which denotes the range of enlightenment which they can spread in both the directions. Since, they do not want to waste their efficiency on trivial things of the world, they want to keep their range minimum.

Also, when we say that the N temples are in a straight line, we mean that that all the temples lie on something like an X-axis in a graph.

Find the minimum enlightenment value such that all the temples can receive it.

Input Format:
The first line contains two integers, N and K - denoting the number of temples and number of monks. The next line contains N integers denoting the position of the temples in the straight line.

Output format:
Print the answer in a new line.

Constraints:
1 <= N <= 105
1 <= K < N
1 <= Positioni <= 107

Update:
The enlightenment value is an integer.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
13 votes
Tags:
AlgorithmsBinary SearchMediumSearchingpartitions
Points:30
16 votes
Tags:
Binary SearchAlgorithms
Points:30
4 votes
Tags:
Binary SearchMedium