AcWing 1227. 分巧克力
原题链接
简单
作者:
月亮事务所
,
2021-01-24 23:57:51
,
所有人可见
,
阅读 334
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N= 100010;
int n, k;
int h[N], w[N];
bool check(int mid)
{
int res = 0;
for(int i=0;i< n; i ++)
{
res +=(h[i] / mid) (w[i] / mid);
if(res >=k)returntrue;
}
int main()
{
scanf(“%d%d",&n,&k);
for (Int i=0;i<n;i ++)scanf("%d%d",&h[i],&w[i]);
int 1 =1,r= 1e5;
while(1<r)
{
int mid-1+r>>1;
if (check(mid)) 1 = mid;
else r = mid 1;
}
printf(“%d\n",r)
return O;
}