80042024-01-12 10:04:16David9320Áruszállítás (75 pont)cpp17Runtime error 7/7587ms6116 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 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/03ms1912 KiB
2Wrong answer0/087ms3356 KiB
3Runtime error0/33ms2320 KiB
4Accepted3/33ms2424 KiB
5Runtime error0/33ms2484 KiB
6Runtime error0/33ms2488 KiB
7Runtime error0/33ms2744 KiB
8Runtime error0/43ms2972 KiB
9Wrong answer0/43ms2936 KiB
10Wrong answer0/43ms2872 KiB
11Runtime error0/43ms3100 KiB
12Runtime error0/43ms3468 KiB
13Wrong answer0/47ms3412 KiB
14Wrong answer0/48ms3492 KiB
15Wrong answer0/47ms3788 KiB
16Accepted4/48ms4028 KiB
17Wrong answer0/48ms4244 KiB
18Wrong answer0/410ms4360 KiB
19Wrong answer0/49ms4432 KiB
20Wrong answer0/410ms4488 KiB
21Wrong answer0/479ms5900 KiB
22Wrong answer0/483ms6116 KiB