18062022-12-03 20:02:35kdbÁruszállítás üres szakaszaicpp11Accepted 50/5032ms11776 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

ostream& operator<<(ostream& os, vector<int>& input)
{
    for (auto i : input)
    {
        os << i << " ";
    }
    os << endl;
    return os;
}

int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    vector<int>vec(n+1);
    for (size_t i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        vec[a]++;
        vec[b]--;
    }
    int c=0;
    for (size_t i = 2; i < n; i++)
    {
        vec[i] += vec[i - 1];
        if (vec[i - 1] != 0 && vec[i] == 0)c++;
    }
    if (vec[1] == 0) c++;
    cout << c << endl;
    return 0;
}
/*
10 4
8 9
1 6
1 3
3 4
-2
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms2104 KiB
2Accepted0/028ms10020 KiB
3Accepted2/22ms2552 KiB
4Accepted2/22ms2412 KiB
5Accepted2/22ms2744 KiB
6Accepted2/22ms2852 KiB
7Accepted2/22ms3060 KiB
8Accepted2/22ms3128 KiB
9Accepted2/22ms3364 KiB
10Accepted2/22ms3564 KiB
11Accepted2/22ms3880 KiB
12Accepted2/23ms4420 KiB
13Accepted3/34ms4412 KiB
14Accepted3/34ms5012 KiB
15Accepted3/34ms5008 KiB
16Accepted3/324ms11380 KiB
17Accepted3/325ms11524 KiB
18Accepted3/327ms11536 KiB
19Accepted3/36ms6896 KiB
20Accepted3/37ms7808 KiB
21Accepted3/332ms11776 KiB
22Accepted3/329ms11584 KiB