rt
Code:
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MAXN = 1e5 + 100;
ll n, k, L, R, h[MAXN], w[MAXN];
bool checker(int x){
ll sum = 0;
for(int i = 1; i <= n; i++){
sum += ((h[i] / x) * (w[i] / x));
}
return sum >= k;
}
int main(){
cin >> n >> k;
for(int i = 1; i <= n; i++){
cin >> h[i] >> w[i];
R = max(R, max(h[i], w[i]));
}
L = 1;
while(L < R){
ll mid = (L + R) / 2;
if(checker(mid)) L = mid + 1;
else R = mid;
}
cout << L - 1 << endl;
return 0;
}