注意二分的范围
#include<iostream>
using namespace std;
const int N = 100010;
int h[N], w[N], n, k;
/*
答案二段性:如果一个边长t满足,那么所有小于等于t的边长一定满足, 此时需要找最大的t
*/
int check(int mid){
int res = 0;
for(int i = 0; i < n; i ++){
res += (h[i] / mid) * (w[i] / mid);
if(res >= k) return 1;
}
return 0;
}
int main(){
cin >> n >> k;
for(int i = 0; i < n; i ++ ) cin >> h[i] >> w[i];
int l = 1, r = 1e5;
while(l < r){
int mid = l + r + 1 >> 1;
if(check(mid)) l = mid;
else r = mid - 1;
}
cout << l << endl;
return 0;
}