80122024-01-12 10:17:08David9320Áruszállítás (75 pont)cpp17Time limit exceeded 67/75400ms3512 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 = megallok[0].first - 1;

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

    cout << eredmeny;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base67/75
1Accepted0/03ms1816 KiB
2Time limit exceeded0/0400ms2040 KiB
3Accepted3/33ms2088 KiB
4Accepted3/33ms2116 KiB
5Accepted3/33ms2188 KiB
6Accepted3/33ms2432 KiB
7Accepted3/33ms2576 KiB
8Accepted4/43ms2784 KiB
9Accepted4/43ms2972 KiB
10Accepted4/43ms3116 KiB
11Accepted4/43ms3216 KiB
12Accepted4/43ms3212 KiB
13Accepted4/413ms3252 KiB
14Accepted4/414ms3388 KiB
15Accepted4/48ms3292 KiB
16Accepted4/439ms3400 KiB
17Accepted4/443ms3396 KiB
18Accepted4/454ms3460 KiB
19Accepted4/423ms3464 KiB
20Accepted4/425ms3476 KiB
21Time limit exceeded0/4400ms3352 KiB
22Time limit exceeded0/4370ms3512 KiB