21532022-12-25 12:20:13bzsofiaÁruszállítás üres szakaszaicpp11Accepted 50/5039ms19336 KiB
#include <iostream>
#include <vector>

using namespace std;

long long n, m, i, a, b, db;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> n >> m;

    vector <long long> x(n + 1);

    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        ++x[a];
        --x[b];
    }

    for (i=2; i<=n; ++i)
    {
        x[i]+=x[i-1];
    }

    x[0]=1;

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

    cout << db;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1696 KiB
2Accepted0/039ms17568 KiB
3Accepted2/22ms2136 KiB
4Accepted2/22ms2268 KiB
5Accepted2/22ms2476 KiB
6Accepted2/22ms2576 KiB
7Accepted2/22ms2572 KiB
8Accepted2/22ms2704 KiB
9Accepted2/22ms2780 KiB
10Accepted2/22ms2880 KiB
11Accepted2/23ms3928 KiB
12Accepted2/23ms4628 KiB
13Accepted3/34ms4836 KiB
14Accepted3/36ms6344 KiB
15Accepted3/34ms6344 KiB
16Accepted3/328ms19336 KiB
17Accepted3/328ms19280 KiB
18Accepted3/332ms19280 KiB
19Accepted3/38ms9792 KiB
20Accepted3/38ms11356 KiB
21Accepted3/337ms19284 KiB
22Accepted3/337ms19284 KiB