# 題目

AP325 Q-4-20. 監看華山練功場

# 解題思路

目前沒東西...

# 程式碼

#include <bits/stdc++.h>
using namespace std;
#define N 100005
bool cmp(pair<int,int> a,pair<int,int> b){
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second <= b.second;
    }
}
int n,x,y;
pair<int,int> p[N];
int main(){
    cin>>n;
    cin>>x>>y;
    for(int i=0;i<n;i++)
        cin>>p[i].first>>p[i].second;
    sort(p,p+n,cmp);
    int i=0,ans=0;
    while(x<y){
        int temp=i;
        while(i<n && p[i].first <= x){
            if(p[i].second > p[temp].second) temp=i;
            i++;
        }
        if(p[temp].first > x || (i>=n && p[temp].second < x)) {
            cout<<"-1";
            return 0;
        }
        ans++;
        x=p[temp].second;
    }
    cout<<ans;
}