39072023-03-03 21:06:08hackemonÁruszállítás üres szakaszaicpp17Wrong answer 45/5085ms5576 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(f[k-1].second < n) ans++;
    
    cout << ans;
    
    return 0;
}



SubtaskSumTestVerdictTimeMemory
base45/50
1Accepted0/03ms1812 KiB
2Accepted0/085ms3372 KiB
3Accepted2/23ms2384 KiB
4Accepted2/23ms2448 KiB
5Accepted2/23ms2584 KiB
6Accepted2/23ms2796 KiB
7Accepted2/23ms3012 KiB
8Accepted2/22ms3128 KiB
9Accepted2/23ms3100 KiB
10Wrong answer0/23ms3436 KiB
11Accepted2/22ms3340 KiB
12Accepted2/23ms3348 KiB
13Accepted3/37ms3496 KiB
14Accepted3/38ms3764 KiB
15Wrong answer0/36ms3700 KiB
16Accepted3/367ms4852 KiB
17Accepted3/368ms4888 KiB
18Accepted3/378ms5144 KiB
19Accepted3/38ms4248 KiB
20Accepted3/39ms4468 KiB
21Accepted3/375ms5576 KiB
22Accepted3/379ms5480 KiB