80502024-01-12 11:29:49David9320Áruszállítás (75 pont)cpp17Time limit exceeded 63/75400ms5112 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, m;
    cin >> n >> m;
    int eredmeny = 0;

    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 j = 1;
    for(int i = 0; i < m; i++) {
        for(int k = max(j, megallok[i].first); k < megallok[i].second; k++) {
            palya[k] = true;
        }
    }

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

    cout << eredmeny - 1;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base63/75
1Accepted0/03ms1812 KiB
2Accepted0/0112ms3620 KiB
3Accepted3/33ms2104 KiB
4Accepted3/33ms2460 KiB
5Accepted3/33ms2480 KiB
6Accepted3/33ms2684 KiB
7Accepted3/33ms2524 KiB
8Accepted4/43ms2608 KiB
9Accepted4/43ms2736 KiB
10Accepted4/43ms2976 KiB
11Accepted4/43ms2972 KiB
12Accepted4/43ms3060 KiB
13Accepted4/47ms3332 KiB
14Accepted4/48ms3216 KiB
15Accepted4/47ms3188 KiB
16Time limit exceeded0/4400ms3456 KiB
17Time limit exceeded0/4358ms2764 KiB
18Time limit exceeded0/4361ms2752 KiB
19Accepted4/412ms3716 KiB
20Accepted4/413ms3888 KiB
21Accepted4/4101ms5064 KiB
22Accepted4/4104ms5112 KiB