思路:非常经典的最大化最小值问题,用二分解决。不过题目没明确说明是最大化最小值,需要分析一下。如果没有学过这种二分题型的同学可以学习一下
代码:
import sys
input = lambda: sys.stdin.readline().strip()
import math
inf = 10 ** 18
def I():
return input()
def II():
return int(input())
def MII():
return map(int, input().split())
def GMI():
return map(lambda x: int(x) - 1, input().split())
def LI():
return input().split()
def LII():
return list(map(int, input().split()))
def LFI():
return list(map(float, input().split()))
fmax = lambda x, y: x if x > y else y
fmin = lambda x, y: x if x < y else y
isqrt = lambda x: int(math.sqrt(x))
'''
'''
def solve():
n, k = MII()
a = LII()
def check(mid):
cnt = 0
for i in range(n):
cnt += a[i] // mid
return cnt >= k
l, r = 1, 10 ** 9
while l <= r:
mid = (l + r) >> 1
if check(mid):
l = mid + 1
else:
r = mid - 1
print(r)
t = 1
# t = II()
for _ in range(t):
solve()

京公网安备 11010502036488号