30872023-02-15 11:13:02CWMÁruszállítás üres szakaszaicpp11Elfogadva 50/50100ms8200 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ÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1944 KiB
2Elfogadva0/0100ms6104 KiB
3Elfogadva2/23ms2220 KiB
4Elfogadva2/23ms2584 KiB
5Elfogadva2/23ms2656 KiB
6Elfogadva2/23ms2740 KiB
7Elfogadva2/23ms2896 KiB
8Elfogadva2/22ms2880 KiB
9Elfogadva2/23ms3044 KiB
10Elfogadva2/23ms3276 KiB
11Elfogadva2/23ms3360 KiB
12Elfogadva2/23ms3272 KiB
13Elfogadva3/38ms3900 KiB
14Elfogadva3/38ms3944 KiB
15Elfogadva3/37ms3764 KiB
16Elfogadva3/371ms7692 KiB
17Elfogadva3/372ms7708 KiB
18Elfogadva3/383ms7768 KiB
19Elfogadva3/39ms4420 KiB
20Elfogadva3/310ms4500 KiB
21Elfogadva3/389ms8200 KiB
22Elfogadva3/390ms8196 KiB