分巧克力

#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
    int n, k;
    int h[100000];
    int w[100000];
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
        cin >> h[i] >> w[i];
    }

    int r = 100001;
    int l=1;
    int ans=0;
    while (l<=r) {
        int mid=(l+r)/2;

        int cnt = 0;
        for (int i = 0; i < n; ++i) {
            cnt += (h[i] / mid) * (w[i] / mid);
        }

        if (cnt >= k) {
            l=mid+1;
            ans=mid;
        }else{
            r=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}
posted @ 2023-12-06 16:41  涨涨涨张  阅读(3)  评论(0编辑  收藏  举报