80022024-01-12 10:03:20David9320Áruszállítás (75 pont)cpp17Runtime error 7/7587ms5284 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;
    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
base7/75
1Runtime error0/03ms1916 KiB
2Wrong answer0/087ms3364 KiB
3Runtime error0/33ms2324 KiB
4Accepted3/33ms2308 KiB
5Runtime error0/33ms2656 KiB
6Runtime error0/33ms2756 KiB
7Runtime error0/33ms2960 KiB
8Runtime error0/43ms3172 KiB
9Wrong answer0/43ms3216 KiB
10Wrong answer0/43ms3288 KiB
11Runtime error0/43ms3352 KiB
12Runtime error0/43ms3344 KiB
13Wrong answer0/48ms3684 KiB
14Wrong answer0/48ms3992 KiB
15Wrong answer0/47ms3988 KiB
16Accepted4/48ms4064 KiB
17Wrong answer0/48ms4044 KiB
18Wrong answer0/49ms4052 KiB
19Wrong answer0/49ms4120 KiB
20Wrong answer0/410ms4012 KiB
21Wrong answer0/482ms5284 KiB
22Wrong answer0/482ms5188 KiB