39052023-03-03 20:59:11hackemonÁruszállítás üres szakaszaicpp17Wrong answer 45/5083ms5580 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 = f[0].second;
    if(f[0].first != 1) ans++;
    
    for(int i = 0;i< k;i++ ) {
        if(legszelso < f[i].first) {
            ans++;
        }
        legszelso = max(legszelso, f[i].second);
    }
    
    if(f[k-1].second != n) ans++;
    
    cout << ans << endl;
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base45/50
1Accepted0/03ms1812 KiB
2Accepted0/083ms3372 KiB
3Accepted2/22ms2096 KiB
4Accepted2/22ms2232 KiB
5Accepted2/23ms2436 KiB
6Accepted2/23ms2656 KiB
7Accepted2/22ms2764 KiB
8Accepted2/22ms2892 KiB
9Accepted2/22ms2972 KiB
10Wrong answer0/23ms3220 KiB
11Accepted2/22ms3188 KiB
12Accepted2/23ms3316 KiB
13Accepted3/37ms3672 KiB
14Accepted3/38ms4020 KiB
15Wrong answer0/36ms3836 KiB
16Accepted3/365ms5220 KiB
17Accepted3/368ms5232 KiB
18Accepted3/378ms5580 KiB
19Accepted3/38ms4336 KiB
20Accepted3/39ms4296 KiB
21Accepted3/375ms5440 KiB
22Accepted3/382ms5440 KiB