18002022-12-03 19:12:51kdbÁruszállítás üres szakaszaicpp11Wrong answer 34/5028ms11316 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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, s = 0, p = 0;
    for (size_t i = 1; i < n + 1; i++)
    {
        s += vec[i];
        if (s != 0 && p == 0)c++;
        p = s;
    }
    cout << c << endl;
    return 0;
}
/*
10 4
8 9
1 6
1 3
3 4
-2
*/
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/03ms1828 KiB
2Accepted0/028ms9764 KiB
3Wrong answer0/22ms2132 KiB
4Wrong answer0/22ms2360 KiB
5Wrong answer0/22ms2336 KiB
6Wrong answer0/22ms2488 KiB
7Wrong answer0/22ms2588 KiB
8Wrong answer0/22ms2660 KiB
9Accepted2/22ms2744 KiB
10Accepted2/22ms2952 KiB
11Wrong answer0/22ms3352 KiB
12Wrong answer0/23ms3940 KiB
13Accepted3/34ms3924 KiB
14Accepted3/34ms4436 KiB
15Accepted3/34ms4332 KiB
16Accepted3/323ms10960 KiB
17Accepted3/323ms10904 KiB
18Accepted3/325ms11164 KiB
19Accepted3/36ms6684 KiB
20Accepted3/36ms7548 KiB
21Accepted3/328ms11316 KiB
22Accepted3/327ms11312 KiB