19492022-12-12 12:53:04bzsofiaÁruszállítás üres szakaszaicpp11Wrong answer 9/5089ms19312 KiB

// Áruszállítás üres szakaszai.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>

using namespace std;

long long n, m, i, a, b, akt, db;
bool elozo;

int main()
{
    cin >> m >> n;

    vector <long long> x(m + 2);

    for (i = 1; i <= n; ++i)
    {
        cin >> a >> b;
        ++x[a];
        --x[b + 1];
    }

    elozo = 1;
    for (i = 1; i <= m+1; ++i)
    {
        akt += x[i];
        if (akt == 0 && elozo)
        {
            elozo = 0;
            ++db;
        }
        else if (akt > 0) elozo = 1;
    }

    cout << db;
}

// 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
SubtaskSumTestVerdictTimeMemory
base9/50
1Accepted0/03ms1812 KiB
2Wrong answer0/089ms17500 KiB
3Accepted2/22ms2180 KiB
4Wrong answer0/22ms2324 KiB
5Wrong answer0/22ms2532 KiB
6Wrong answer0/22ms2612 KiB
7Accepted2/22ms2736 KiB
8Wrong answer0/22ms2752 KiB
9Wrong answer0/22ms2760 KiB
10Wrong answer0/22ms2756 KiB
11Accepted2/23ms3832 KiB
12Wrong answer0/23ms4636 KiB
13Wrong answer0/36ms4580 KiB
14Wrong answer0/38ms6064 KiB
15Wrong answer0/37ms6076 KiB
16Wrong answer0/367ms18888 KiB
17Wrong answer0/368ms19100 KiB
18Wrong answer0/375ms19076 KiB
19Wrong answer0/310ms9844 KiB
20Wrong answer0/313ms11348 KiB
21Accepted3/379ms19312 KiB
22Wrong answer0/385ms19276 KiB