39062023-03-03 21:01:50hackemonÁruszállítás üres szakaszaicpp17Wrong answer 45/5082ms5828 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 << endl;
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base45/50
1Accepted0/03ms1812 KiB
2Accepted0/082ms3404 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2428 KiB
5Accepted2/23ms2640 KiB
6Accepted2/23ms2724 KiB
7Accepted2/23ms2992 KiB
8Accepted2/22ms2984 KiB
9Accepted2/23ms3184 KiB
10Wrong answer0/23ms3384 KiB
11Accepted2/22ms3468 KiB
12Accepted2/23ms3476 KiB
13Accepted3/37ms3516 KiB
14Accepted3/38ms3656 KiB
15Wrong answer0/36ms3828 KiB
16Accepted3/365ms5096 KiB
17Accepted3/367ms5308 KiB
18Accepted3/376ms5516 KiB
19Accepted3/38ms4376 KiB
20Accepted3/39ms4636 KiB
21Accepted3/375ms5828 KiB
22Accepted3/376ms5740 KiB