75502024-01-09 14:16:07rennÁruszállítás üres szakaszaicpp17Accepted 50/5035ms10692 KiB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);

    int n, m, a, b;
    cin >> n >> m;

    vector<int> csomag(n, 0);
    while(m--)
    {
        cin >> a >> b;
        csomag[a-1]++;
        csomag[b-1]--;
    }
    int uresszam = 0, t = 0, j = n-1;


    bool prev_ures = false;
    bool ures = false;

    for(int i = 0; i < n; i++)
    {
        t += csomag[i];

        prev_ures = ures;
        ures = t == 0;

        uresszam += ures && i != j && prev_ures != ures;
    }

    cout << uresszam << "\n";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1832 KiB
2Accepted0/035ms9728 KiB
3Accepted2/23ms2232 KiB
4Accepted2/23ms2316 KiB
5Accepted2/23ms2320 KiB
6Accepted2/23ms2440 KiB
7Accepted2/23ms2524 KiB
8Accepted2/23ms2528 KiB
9Accepted2/23ms2908 KiB
10Accepted2/23ms2904 KiB
11Accepted2/23ms2940 KiB
12Accepted2/23ms3560 KiB
13Accepted3/34ms3540 KiB
14Accepted3/34ms4064 KiB
15Accepted3/34ms4200 KiB
16Accepted3/327ms10440 KiB
17Accepted3/327ms10692 KiB
18Accepted3/329ms10636 KiB
19Accepted3/37ms5956 KiB
20Accepted3/38ms6872 KiB
21Accepted3/332ms10636 KiB
22Accepted3/332ms10640 KiB