18052022-12-03 19:54:45kdbÁruszállítás üres szakaszaicpp11Wrong answer 48/5037ms11416 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 = 1; i < n+1; i++)
    {
        vec[i] += vec[i - 1];
        if (vec[i] != 0 && vec[i - 1] == 0)c++;
    }
    if (vec[n] == 0 && vec[n-1]==0) c++;
    cout << c << endl;
    return 0;
}
/*
10 4
8 9
1 6
1 3
3 4
-2
*/
SubtaskSumTestVerdictTimeMemory
base48/50
1Wrong answer0/03ms1828 KiB
2Accepted0/037ms9760 KiB
3Accepted2/22ms2264 KiB
4Wrong answer0/22ms2464 KiB
5Accepted2/22ms2528 KiB
6Accepted2/22ms2732 KiB
7Accepted2/22ms2960 KiB
8Accepted2/22ms3012 KiB
9Accepted2/22ms3016 KiB
10Accepted2/22ms3004 KiB
11Accepted2/22ms3308 KiB
12Accepted2/23ms3700 KiB
13Accepted3/34ms3700 KiB
14Accepted3/34ms4480 KiB
15Accepted3/34ms4424 KiB
16Accepted3/324ms11048 KiB
17Accepted3/324ms10996 KiB
18Accepted3/326ms11000 KiB
19Accepted3/36ms6576 KiB
20Accepted3/37ms7688 KiB
21Accepted3/328ms11408 KiB
22Accepted3/332ms11416 KiB