39082023-03-03 21:06:51hackemonÁruszállítás üres szakaszaicpp17Accepted 50/5083ms5480 KiB
#include <bits/stdc++.h>
using namespace std;


int main()
{
    int n, k;
    cin >> n >> k;
    vector<pair<int,int>> f(k);
    for(int i = 0;i < k;i++ ) {
        int a, b;
        cin >> a >> b;
        f[i] = {a, b};
    }
    sort(f.begin(), f.end());
    
    int ans = 0;
    
    int legszelso = 1;
     
    for(int i = 0;i< k;i++ ) {
        if(legszelso < f[i].first) {
            ans++;
        }
        legszelso = max(legszelso, f[i].second);
    }
    
    if(legszelso < n) ans++;
    
    cout << ans;
    
    return 0;
}



SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1808 KiB
2Accepted0/083ms3408 KiB
3Accepted2/23ms2272 KiB
4Accepted2/23ms2488 KiB
5Accepted2/23ms2640 KiB
6Accepted2/22ms2756 KiB
7Accepted2/22ms3004 KiB
8Accepted2/22ms3084 KiB
9Accepted2/22ms3084 KiB
10Accepted2/22ms3204 KiB
11Accepted2/23ms3284 KiB
12Accepted2/23ms3368 KiB
13Accepted3/37ms3572 KiB
14Accepted3/38ms3784 KiB
15Accepted3/36ms3724 KiB
16Accepted3/367ms4896 KiB
17Accepted3/368ms4976 KiB
18Accepted3/378ms4976 KiB
19Accepted3/38ms4076 KiB
20Accepted3/39ms4040 KiB
21Accepted3/375ms5192 KiB
22Accepted3/379ms5480 KiB