19582022-12-12 13:38:02bzsofiaÁruszállítás üres szakaszaicpp11Wrong answer 20/5039ms19860 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()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    cin >> m >> n;

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

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

    for (i = 1; i <= m; ++i)
    {
        x[i] += x[i - 1];
    }
    
    for (i = 1; i <= m; ++i)
    {
        if (x[i] == 0 && x[i-1]!=0)
        {
            ++db;
        }
    }
    if (x[1] == 0) ++db;

    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
base20/50
1Accepted0/03ms1828 KiB
2Accepted0/039ms17692 KiB
3Accepted2/22ms2228 KiB
4Accepted2/22ms2300 KiB
5Wrong answer0/22ms2304 KiB
6Wrong answer0/22ms2432 KiB
7Accepted2/22ms2504 KiB
8Wrong answer0/22ms2632 KiB
9Runtime error0/22ms2948 KiB
10Runtime error0/22ms3148 KiB
11Accepted2/23ms4104 KiB
12Wrong answer0/23ms4880 KiB
13Wrong answer0/34ms4764 KiB
14Wrong answer0/36ms6296 KiB
15Wrong answer0/34ms6296 KiB
16Accepted3/328ms19284 KiB
17Accepted3/328ms19492 KiB
18Accepted3/329ms19440 KiB
19Wrong answer0/38ms10228 KiB
20Wrong answer0/38ms11936 KiB
21Wrong answer0/332ms19720 KiB
22Accepted3/334ms19860 KiB