Python 代码
N, K = map(int, input().split())
MAX = 0
cakes = []
for _ in range(N):
w, h = map(int, input().split())
MAX = max(MAX, w, h)
cakes.append([w, h])
def cal(size):
cnt = 0
for w, h in cakes:
cnt += (h // size) * (w // size)
return cnt
l, r = 0, MAX
while l < r:
mid = l + r + 1 >> 1
if cal(mid) >= K: l = mid
else: r = mid - 1
print(l)