AcWing 1227. 分巧克力
原题链接
简单
作者:
autumn_0
,
2021-04-03 12:11:30
,
所有人可见
,
阅读 299
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define INF 100010;
using namespace std;
const int N = 100010;
int wid[N];
int len[N];
int n, k;
int get_sum(int u)
{
int sum = 0;
for(int i = 0 ; i < n ; i ++ )
sum += (wid[i] / u) * (len[i] / u);
return sum;
}
int main()
{
//读入数据
scanf("%d%d", &n, &k);
for(int i = 0; i < n; i++) scanf("%d%d", &wid[i], &len[i]);
int l = 0, r = N;
while(l < r)
{
int mid = l + r + 1>> 1;
if(get_sum(mid) >= k) l = mid;
else r = mid - 1;
}
cout << l << endl;
return 0;
}