#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <time.h>
#include <map>
#include <algorithm>
#include<memory.h>
#include <limits.h>
#define MAX 0x0fffffff
using namespace std;
class TL
{
public:
int st;
int en;
TL(int st,int en)
{
this->st = st;
this->en = en;
}
TL()
{
st = en =-1;
}
};
bool cmp(TL tl1,TL tl2)
{
if(tl1.en<tl2.en)return true;
return false;
}
TL V[1001];
int k = 0;
void Init()
{
k = 0;
}
int main()
{
//freopen("D:\\input.txt","r",stdin);
int n;
while(cin>>n)
{
Init();
int st,en;
for(int i=0;i<n;i++)
{
cin>>st>>en;
V[i] = TL(st,en);
k++;
}
sort(V,V+k,cmp);
int total = 0;
int pre = 0;
for(int i=0;i<k;i++)
{
if(V[i].st>=pre)
{
total++;
pre = V[i].en;
}
}
cout<<total<<endl;
}
}
/**************************************************************
Problem: 1463
User: cust123
Language: C++
Result: Accepted
Time:10 ms
Memory:1528 kb
****************************************************************/
题目1463:招聘会
最新推荐文章于 2022-07-01 10:48:32 发布