题目
解释
- 注意到本题的巧克力面积不可以合并在一起计算
- 只能对每一个独立的巧克力的面积取最大边长
代码段
#include<iostream>
#include<cmath>
#define ll long long
using namespace std;
const int N=1e5+10;
int n,k;
struct c
{
int x,y;
}co[N];
bool check(int mid)
{
int res=0;
for(int i=1;i<=n;i++)
{
res+=(co[i].x/mid)*(co[i].y/mid);
if(res>=k)return 1;
}
if(res<k)return 0;
}
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>co[i].x;
cin>>co[i].y;
}
int l=0,r=N;
while(l<r)
{
int mid=(l+r+1)/2;
if(check(mid))
l=mid;
else
r=mid-1;
}
cout<<l<<endl;
}