AcWing 1227. 分巧克力
原题链接
简单
作者:
Shelcon
,
2024-11-24 18:07:57
,
所有人可见
,
阅读 4
n,k=map(int,input().split())
choc=[]
for i in range(n):
choc.append(list(map(int,input().split())))
maxs=0
for i in range(len(choc)):
maxs=max(maxs,max(choc[i]))
left,right=0,maxs+1
def check(x):
res=0
for i in range(len(choc)):
if choc[i][0]>=x and choc[i][1]>=x:
res+=(choc[i][0]//x)*(choc[i][1]//x)
if res<k:
return False
else:
return True
while left+1<right:
mid=(left+right)//2
if check(mid):
left=mid
else:
right=mid
if check(right):
print(right)
else:
print(left)