﻿HDU 2037 今年暑假不AC(贪心)-Ocrosoft

# 今年暑假不AC

Problem Description
“今年暑假不AC？”
“是的。”
“那你干什么呢？”
“看世界杯呀，笨蛋！”
“@#\$%^&*%…”

Input

Output

Sample Input
12
1 3
3 4
0 7
3 8
15 19
15 20
10 15
8 18
6 12
5 10
4 14
2 9
0

Sample Output
5

```#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <cstring>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#define PI acos(-1.0)
#define ms(a) memset(a,0,sizeof(a))
#define msp memset(mp,0,sizeof(mp))
#define msv memset(vis,0,sizeof(vis))
using namespace std;
//#define LOCAL
struct Node
{
int b;
int e;
}t;
bool cmp(Node n1,Node n2)
{
if(n1.e==n2.e)return n1.b<n2.b;
return n1.e<n2.e;
}
vector<Node> v;
int main()
{
#ifdef LOCAL
freopen("in.txt", "r", stdin);
#endif // LOCAL
ios::sync_with_stdio(false);
int n;
while(cin>>n&&n)
{
v.clear();
while(n--)
{
cin>>t.b>>t.e;
v.push_back(t);
}
sort(v.begin(),v.end(),cmp);
int ans=1;
for(int i=1;i<v.size();i++)
{
t=v[i];
if(t.b>=v[i-1].e)ans++;
else v.erase(v.begin()+i),i--;
}
printf("%d\n",ans);
}
return 0;
}```