class Solution(object):
def maximumTastiness(self, price, k):
"""
:type price: List[int]
:type k: int
:rtype: int
"""
def check(x):
prev = -float("inf")
cnt = 0
for p in price:
if p - prev >= x:
prev = p
cnt += 1
return cnt >= k
price.sort()
left, right = 0, price[-1] - price[0]
while left < right:
mid = (left + right + 1) // 2
if check(mid):
left = mid
else:
right = mid - 1
return left