18042022-12-03 19:54:23kdbTáblajátékcpp11Wrong answer 0/503ms3156 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
base0/50
1Wrong answer0/03ms1828 KiB
2Wrong answer0/02ms2204 KiB
3Wrong answer0/32ms2308 KiB
4Wrong answer0/32ms2512 KiB
5Wrong answer0/32ms2540 KiB
6Wrong answer0/32ms2736 KiB
7Wrong answer0/32ms2816 KiB
8Wrong answer0/32ms2876 KiB
9Wrong answer0/32ms3156 KiB
10Wrong answer0/32ms2896 KiB
11Wrong answer0/32ms2888 KiB
12Wrong answer0/32ms3024 KiB
13Wrong answer0/42ms3028 KiB
14Wrong answer0/42ms3020 KiB
15Wrong answer0/42ms3020 KiB
16Wrong answer0/42ms3024 KiB
17Wrong answer0/42ms3020 KiB