3087 2023. 02. 15 11:13:02 CWM Áruszállítás üres szakaszai cpp11 Elfogadva 50/50 100ms 8200 KiB
// nemesGyak000.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
    int length, q;
    cin >> length >> q;
    vector<pair<int, int>> times;
    for (size_t i = 0; i < q; i++)
    {
        int p, n;
        cin >> p >> n;
        times.push_back({p,1});
        times.push_back({n,-1 });
    }
    sort(times.begin(), times.end());
    int Index = 1;
    int SUM = 0;
    int rn = 0;
    int beginning = -1;
    if (times[0].first != 1) rn++;
    for (size_t i = 0; i < times.size(); i++)
    {
        SUM += times[i].second;
        if (times[i].first!=length) {
            if (beginning == times[i].first) {
                rn--;
                beginning = -1;
            }
            if (SUM == 0) {
                rn++;
                beginning = times[i].first;
            }
        }
    }
    cout << rn << "\n";
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Részfeladat Összpont Teszt Verdikt Idő Memória
base 50/50
1 Elfogadva 0/0 3ms 1944 KiB
2 Elfogadva 0/0 100ms 6104 KiB
3 Elfogadva 2/2 3ms 2220 KiB
4 Elfogadva 2/2 3ms 2584 KiB
5 Elfogadva 2/2 3ms 2656 KiB
6 Elfogadva 2/2 3ms 2740 KiB
7 Elfogadva 2/2 3ms 2896 KiB
8 Elfogadva 2/2 2ms 2880 KiB
9 Elfogadva 2/2 3ms 3044 KiB
10 Elfogadva 2/2 3ms 3276 KiB
11 Elfogadva 2/2 3ms 3360 KiB
12 Elfogadva 2/2 3ms 3272 KiB
13 Elfogadva 3/3 8ms 3900 KiB
14 Elfogadva 3/3 8ms 3944 KiB
15 Elfogadva 3/3 7ms 3764 KiB
16 Elfogadva 3/3 71ms 7692 KiB
17 Elfogadva 3/3 72ms 7708 KiB
18 Elfogadva 3/3 83ms 7768 KiB
19 Elfogadva 3/3 9ms 4420 KiB
20 Elfogadva 3/3 10ms 4500 KiB
21 Elfogadva 3/3 89ms 8200 KiB
22 Elfogadva 3/3 90ms 8196 KiB