80362024-01-12 11:02:42David9320Áruszállítás (75 pont)cpp17Time limit exceeded 63/75361ms5780 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    vector<pair<int, int>> megallok(m);
    vector<bool> palya(n + 1);

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

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

    int j = 1;
    for(int i = 0; i < m; i++) {
        if(megallok[i].second - 1 > j && j > megallok[i].first) {
            for(j; j < megallok[i].second; j++) {
                palya[j] = true;
            }
        } else {
            for(int k = megallok[i].first; k < megallok[i].second; k++) {
                palya[k] = true;
            }
        }
    }

    for(int i = 1; i < n; i++) {
        if(!palya[i]) {
            eredmeny++;
        }
    }

    cout << eredmeny;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base63/75
1Accepted0/03ms1812 KiB
2Accepted0/0114ms4008 KiB
3Accepted3/33ms2400 KiB
4Accepted3/33ms2556 KiB
5Accepted3/33ms2576 KiB
6Accepted3/33ms2784 KiB
7Accepted3/33ms3000 KiB
8Accepted4/43ms3208 KiB
9Accepted4/43ms3420 KiB
10Accepted4/43ms3672 KiB
11Accepted4/43ms3728 KiB
12Accepted4/43ms3736 KiB
13Accepted4/48ms3984 KiB
14Accepted4/48ms3956 KiB
15Accepted4/47ms3968 KiB
16Time limit exceeded0/4358ms4204 KiB
17Time limit exceeded0/4361ms3452 KiB
18Time limit exceeded0/4349ms4408 KiB
19Accepted4/412ms4400 KiB
20Accepted4/413ms4680 KiB
21Accepted4/4101ms5780 KiB
22Accepted4/4107ms5704 KiB