1 条题解

  • 0
    @ 2026-10-25 18:02:03

    思路

    闭区间最少选点,按右端点排序,端点相等可以共用,区别区间调度和区间合并。

    参考程序(C++11)

    #include <bits/stdc++.h>
    using namespace std;
    int main(){int n;cin>>n;vector<pair<int,int>>a(n);for(auto &p:a)cin>>p.second>>p.first;sort(a.begin(),a.end());int cur=-1,ans=0;for(auto p:a)if(p.second>cur){ans++;cur=p.first;}cout<<ans<<'\n';}
    
    • 1

    信息

    ID
    1335
    时间
    1000ms
    内存
    64MiB
    难度
    普及−
    标签
    递交数
    1
    已通过
    1
    上传者