1 条题解
-
0
按区间右端点贪心选择整数覆盖所有闭区间,支持10000个区间。
#include <bits/stdc++.h> using namespace std; int main(){ios::sync_with_stdio(false);cin.tie(nullptr); int n;cin>>n;vector<pair<int,int>>a(n);for(auto&[end,start]:a)cin>>start>>end;sort(a.begin(),a.end());int last=-1,answer=0;for(auto[end,start]:a)if(start>last){last=end;answer++;}cout<<answer<<"\n"; return 0; }
- 1
信息
- ID
- 3999
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者