59042023-10-05 12:26:21mmatedÁruszállítás üres szakaszaicpp11Accepted 50/5056ms14312 KiB
#include <bits/stdc++.h>
using namespace std;
#define f(i,k,n) for(int i=k; i<n; i++)
#define ll long long
const int inf = INT_MAX;

void solve()
{
    int n,m;
    cin>>n>>m;
    int x,y;
    vector<vector<int>> a;
    f(i,0,m)
    {
        cin>>x>>y;
        a.push_back({x,y});
    }
    sort(a.begin(),a.end());
    int c=0;
    int e=1;
    f(i,0,m)
    {
        if(e<a[i][0])   c++;
        e=max(e,a[i][1]);
    }
    if(e<n) c++;
    cout<<c;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin>>t;
    while(t--)  solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1736 KiB
2Accepted0/056ms12920 KiB
3Accepted2/23ms2176 KiB
4Accepted2/22ms2260 KiB
5Accepted2/23ms2484 KiB
6Accepted2/23ms2528 KiB
7Accepted2/23ms2748 KiB
8Accepted2/23ms2964 KiB
9Accepted2/23ms3180 KiB
10Accepted2/22ms3372 KiB
11Accepted2/22ms3464 KiB
12Accepted2/23ms3484 KiB
13Accepted3/34ms4144 KiB
14Accepted3/36ms4544 KiB
15Accepted3/34ms4420 KiB
16Accepted3/341ms13912 KiB
17Accepted3/341ms13976 KiB
18Accepted3/348ms13956 KiB
19Accepted3/37ms5308 KiB
20Accepted3/37ms5384 KiB
21Accepted3/350ms14184 KiB
22Accepted3/352ms14312 KiB