80012024-01-12 09:59:38David9320Áruszállítás (75 pont)cpp17Runtime error 51/7589ms9564 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> megallok(m);

    for(int i = 0; i < m; i++) {
        cin >> megallok[i].first >> megallok[i].second;
    }

    sort(megallok.begin(), megallok.end());
    int eredmeny = 0;
    cout << endl;

    int j = 0;
    for(int i = 1; i < n; i++) {
        if(i >= megallok[j].second) {
            j++;
            i--;
            continue;
        }
        if(j >= megallok.size()) {
            eredmeny++;
        } else if(i < megallok[j].first) {
            eredmeny++;
        } else if(i == megallok[j].second - 1) {
            j++;
        }
    }

    cout << eredmeny;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base51/75
1Runtime error0/03ms1916 KiB
2Accepted0/089ms4772 KiB
3Runtime error0/33ms3708 KiB
4Accepted3/33ms3792 KiB
5Runtime error0/33ms4108 KiB
6Runtime error0/33ms4088 KiB
7Runtime error0/33ms4340 KiB
8Runtime error0/43ms4552 KiB
9Accepted4/43ms4684 KiB
10Accepted4/43ms4852 KiB
11Runtime error0/43ms4744 KiB
12Runtime error0/43ms4748 KiB
13Accepted4/47ms5088 KiB
14Accepted4/48ms5256 KiB
15Accepted4/47ms5220 KiB
16Accepted4/48ms5440 KiB
17Accepted4/48ms5556 KiB
18Accepted4/49ms5808 KiB
19Accepted4/49ms5784 KiB
20Accepted4/410ms6032 KiB
21Accepted4/479ms8476 KiB
22Accepted4/483ms9564 KiB