30712023-02-14 10:00:47CWMÁruszállítás üres szakaszaicpp11Hibás válasz 6/5096ms8224 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;
    bool Switch = true;
    for (size_t i = 0; i < times.size(); i++)
    {
        SUM += times[i].second;
        if (times[i].first != Index) {
            Index = times[i].first;
            if (Switch && SUM == 0) {
                rn++;
                Switch = false;
            }
            if (SUM != 0) {
                Switch = true;
            }
        }
    }
    cout << rn;
}

// 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
base6/50
1Elfogadva0/03ms1812 KiB
2Hibás válasz0/096ms6136 KiB
3Hibás válasz0/23ms2228 KiB
4Hibás válasz0/23ms2436 KiB
5Hibás válasz0/23ms2524 KiB
6Elfogadva2/23ms2520 KiB
7Hibás válasz0/23ms2648 KiB
8Hibás válasz0/23ms2864 KiB
9Elfogadva2/22ms2948 KiB
10Elfogadva2/23ms2948 KiB
11Hibás válasz0/23ms3076 KiB
12Hibás válasz0/23ms3332 KiB
13Hibás válasz0/38ms3924 KiB
14Hibás válasz0/39ms4004 KiB
15Hibás válasz0/37ms3880 KiB
16Hibás válasz0/371ms7676 KiB
17Hibás válasz0/372ms7948 KiB
18Hibás válasz0/382ms7912 KiB
19Hibás válasz0/39ms4444 KiB
20Hibás válasz0/310ms4540 KiB
21Hibás válasz0/387ms8116 KiB
22Hibás válasz0/390ms8224 KiB