16032022-11-28 20:36:43kicsiboglarÁruszállítás üres szakaszaicpp11Accepted 50/5050ms35312 KiB
#include <iostream>
#include <vector>
#define ll long long 

using namespace std;

ll n, m, i, j, a, b;

int main()
{
    ios::sync_with_stdio(false);
    cin >> n >> m;
    vector <ll> x(2 * n + 2);
    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        x[a * 2]++;
        x[b * 2]--;
    }
    n = 2 * n;
    ll db = 0;
    x[n + 1] = 100000000;
    for (i = 3; i <= n; ++i)
    {
        x[i] += x[i - 1];
        if (x[i] != 0 && x[i - 1] == 0) db++;
    }
    if (x[n - 1] == 0 && x[n] == 0) db++;
    cout << db << "\n";

    return 0;
}

SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/046ms33156 KiB
3Accepted2/22ms2260 KiB
4Accepted2/22ms2460 KiB
5Accepted2/22ms2696 KiB
6Accepted2/22ms3140 KiB
7Accepted2/22ms3180 KiB
8Accepted2/22ms3064 KiB
9Accepted2/22ms3196 KiB
10Accepted2/22ms3396 KiB
11Accepted2/23ms5204 KiB
12Accepted2/24ms6284 KiB
13Accepted3/34ms6560 KiB
14Accepted3/37ms9408 KiB
15Accepted3/36ms9632 KiB
16Accepted3/339ms35056 KiB
17Accepted3/335ms35204 KiB
18Accepted3/339ms35312 KiB
19Accepted3/39ms16580 KiB
20Accepted3/312ms19724 KiB
21Accepted3/345ms35292 KiB
22Accepted3/350ms35164 KiB