全部评论 2

  • #include<bits/stdc++.h>
    using namespace std;
    
    const int maxn = 114514;
    int a[maxn], n, len, m;
    
    bool check(int mid)
    {
        int cnt = 0;
        int now = 0;
        for(int i = 1; i <= n; ++i)
        {
            if(a[i] - a[now] < mid)
            {
                cnt++;
            }
            else
            {
                now = i;
            }
        }
        return cnt <= m;
    }
    
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
    
        cin >> len >> n >> m;
        if(n == 0)
        {
            cout << len << endl;
            return 0;
        }
        for(int i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        sort(a + 1, a + 1 + n);
        a[0] = 0;
        a[n+1] = len;
    
        int l = 1, r = len;
        while(l < r)
        {
            int mid = (l + r + 1) >> 1;
            if(check(mid))
                l = mid;
            else
                r = mid - 1;
        }
        cout << l << endl;
        return 0;
    }
    
    

    我看着像跳石头(A49),就看了一下提交记录,发现是这道题,帮你改了,能A

    2026-08-29 来自 广东

    1
  • 先说一下是哪一题

    2026-08-29 来自 广东

    1

热门讨论