AcWing 1227. 分巧克力
原题链接
中等
作者:
Value
,
2020-07-06 19:32:04
,
所有人可见
,
阅读 562
#include <iostream>
using namespace std;
const int N = 1e5 + 10;
struct node{
int h, w;
};
node food[N];
int n, k;
bool check(int t){
int cnt = 0;
for(int i = 0; i < n; i ++ ) cnt += (food[i].h / t) * (food[i].w / t);
return cnt >= k;
}
int main(){
cin >> n >> k;
for(int i = 0; i < n; i ++ ) cin >> food[i].h >> food[i].w;
int l = 1, r = N;
while(l < r){
int mid = l + r + 1 >> 1;
if(check(mid)) l = mid;
else r = mid - 1;
}
cout << l << endl;
return 0;
}