社区讨论
为啥我编译不了啊
P1803凌乱的yyy / 线段覆盖参与者 3已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @lu7thy5e
- 此快照首次捕获于
- 2024/03/26 11:28 2 年前
- 此快照最后确认于
- 2024/03/26 16:49 2 年前
CPP
#include<iostream>
#include<vector>
#include<iomanip>
#include<string.h>
#include<algorithm>
#include<math.h>
using namespace std;
bool cmp(time f,time p)
{
return f.b<p.b;
}
struct time
{
int a;
int b;
};
int main()
{
struct time sj[1000001];
int n,t;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>sj[i].a>>sj[i].b;
}
sort(sj,sj+n,cmp);
int mark=0;
int count=1;
for(int i=0;i<n;i++)
{
if(sj[i].a>mark)
{
count++;
mark=sj[i].b;
}
}
cout<<count;
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...