8262022-01-18 11:44:51zsebiÁruszállítás üres szakaszaicpp11Accepted 50/5097ms19556 KiB
#include <iostream>
//#include <fstream>
#include <algorithm>

using namespace std;

struct aru
{
    int k,v;

};
aru y[1000001];
int has (aru a, aru b)
{
    if(a.k<b.k) return 1;
    else return 0;
}

//ifstream cin("aru.in");
//ofstream cout("aru.out");
long long n,m,i,x[1000002],a,b,db,db2;

int main()
{
    cin>>n>>m;
    for(i=1;i<=m;++i)
    {
        cin>>a>>b;

        x[a]++;
        x[b]--;

    }
    //sort(y+1,y+m+1,has);
    for(i=1;i<=n;++i)
    {
        x[i]+=x[i-1];

    }
//for(i=1;i<=n;++i)cout<<x[i];
x[n]=5;
    for(i=1;i<=n;++i)
    {
        if(x[i]==0)db++;
        else if( x[i-1]==0&&db>=1)
        {
            db2++;
            db=0;
        }

    }
    cout<<db2;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms1808 KiB
2Accepted0/087ms18872 KiB
3Accepted2/21ms3340 KiB
4Accepted2/21ms3344 KiB
5Accepted2/21ms3352 KiB
6Accepted2/21ms3352 KiB
7Accepted2/21ms3360 KiB
8Accepted2/22ms3360 KiB
9Accepted2/22ms3372 KiB
10Accepted2/22ms3372 KiB
11Accepted2/22ms4220 KiB
12Accepted2/23ms4732 KiB
13Accepted3/36ms4868 KiB
14Accepted3/38ms6424 KiB
15Accepted3/36ms6420 KiB
16Accepted3/397ms19508 KiB
17Accepted3/381ms19524 KiB
18Accepted3/378ms19520 KiB
19Accepted3/310ms10100 KiB
20Accepted3/312ms11648 KiB
21Accepted3/376ms19520 KiB
22Accepted3/389ms19556 KiB