题目描述
include [HTML_REMOVED]
using namespace std;
int n, k;
int const N = 100010;
int w[N], h[N];
int check(int mid)
{
int num = 0;
for (int i = 0; i < n; i)
{
num += w[i] / mid * (h[i] / mid);
if (num >= k) return 1;
}
return 0;
}
int main()
{
cin >> n >> k;
for (int i = 0; i < n; i)
{
cin >> w[i] >> h[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 << r;
return 0;
}
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla