36452023-03-01 14:43:24Erik_GepardÁruszállítás üres szakaszaicpp17Accepted 50/5035ms5532 KiB
#include <bits/stdc++.h>
using namespace std;


void solve(){
    int n, m;
    cin>>n>>m;
    vector<pair<int,int>> a(m);
    for(int i=0; i<m; i++){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(), a.end());
    int covered=1, ans=0;
    for(int i=0; i<m; i++){
        if(a[i].first>covered){
            ans++;
        }
        covered=max(a[i].second, covered);
    }
    if(n>covered){
        ans++;
    }
    cout<<ans<<"\n";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1832 KiB
2Accepted0/035ms3508 KiB
3Accepted2/23ms2248 KiB
4Accepted2/23ms2384 KiB
5Accepted2/23ms2620 KiB
6Accepted2/23ms2820 KiB
7Accepted2/23ms2908 KiB
8Accepted2/23ms3040 KiB
9Accepted2/23ms3248 KiB
10Accepted2/22ms3312 KiB
11Accepted2/22ms3316 KiB
12Accepted2/23ms3448 KiB
13Accepted3/34ms3616 KiB
14Accepted3/34ms3924 KiB
15Accepted3/34ms3984 KiB
16Accepted3/327ms5008 KiB
17Accepted3/328ms5092 KiB
18Accepted3/332ms5032 KiB
19Accepted3/34ms4024 KiB
20Accepted3/34ms4060 KiB
21Accepted3/332ms5448 KiB
22Accepted3/334ms5532 KiB