39042023-03-03 20:58:16hackemonÁruszállítás üres szakaszaicpp17Wrong answer 19/5081ms5580 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 = f[i].second;
        }
    }
    
    if(f[k-1].second != n) ans++;
    
    cout << ans << endl;
    
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base19/50
1Accepted0/03ms1808 KiB
2Wrong answer0/081ms3408 KiB
3Accepted2/23ms2240 KiB
4Accepted2/22ms2316 KiB
5Accepted2/23ms2440 KiB
6Wrong answer0/22ms2556 KiB
7Accepted2/22ms2628 KiB
8Wrong answer0/23ms2756 KiB
9Wrong answer0/23ms2996 KiB
10Wrong answer0/23ms3248 KiB
11Accepted2/22ms3264 KiB
12Wrong answer0/23ms3396 KiB
13Wrong answer0/37ms3776 KiB
14Wrong answer0/38ms3992 KiB
15Wrong answer0/36ms3928 KiB
16Accepted3/364ms5116 KiB
17Accepted3/365ms5228 KiB
18Accepted3/375ms5328 KiB
19Wrong answer0/38ms4232 KiB
20Wrong answer0/39ms4172 KiB
21Wrong answer0/374ms5324 KiB
22Wrong answer0/376ms5580 KiB