1 条题解

  • 1
    @ 2024-11-22 16:17:24
    #include<iostream>
    using namespace std;
    typedef long long LL;
    const int N = 100010;
    int a[N], b[N];
    int n, k;
    bool check(int x)
    {
        LL res = 0;
        for (int i = 1; i <= n; ++ i)
        {
            int h = a[i] / x, w = b[i] / x;
            res += h * w;
            if (res >= k) return true;
        }
        return false;
    }
    int main()
    {
        cin >> n >> k;
        for (int i = 1; i <= n; ++ i) scanf("%d%d", &a[i], &b[i]);
        int l = 1, r = 1e9;
        while (l < r)
        {
            int mid = l + r + 1 >> 1;
            if (check(mid)) l = mid;
            else r = mid - 1;
        }
        cout << l << endl;
        return 0;
    }
    
    • 1

    信息

    ID
    5500
    时间
    1000ms
    内存
    512MiB
    难度
    8
    标签
    递交数
    19
    已通过
    5
    上传者