- 取石子
线段**
- 2025-10-3 22:31:45 @
#include<bits/stdc++.h>
using namespace std;
struct yyy{
int s;
int e;
}a[1000000];
bool cmp(yyy x,yyy y){
return x.e<y.e;
}
int main(){
int n;
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i].s>>a[i].e;
}
sort(a+1,a+n+1,cmp);
int t=-2e9,cnt=0;
for(int i=1;i<=n;i++)
if(a[i].s>=t){
t=a[i].e;
cnt+=1;
}
cout<<cnt;
return 0;
}
线段覆盖
4 条评论
-
孙易莘EASON @ 2025-10-3 22:42:08
呵
-
2025-10-3 22:42:05@
阶乘末尾零统计发一下呗
-
2025-10-3 22:40:07@
6
-
2025-10-3 22:32:16@
看一下我的训练呗
- 1
信息
- ID
- 116
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 8
- 标签
- 递交数
- 56
- 已通过
- 9
- 上传者