21012022-12-19 13:53:58tamasmarkÁruszállítás üres szakaszaicpp17Hibás válasz 0/503ms4204 KiB
// nt allomas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <deque>

using namespace std;

struct allomas
{
    long long sz;
    long long meg;
};

allomas x[10000];

long long n, m, i, a, b,db;
bool t;

int main()
{
    cin >> n >> m;
    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        x[a].sz++;
        x[b +1].sz--;
        x[a].meg = 1;
        x[b].meg = 2;
    }
    
    for (i = 2; i <=n; ++i)
    {
        x[i].sz = x[i - 1].sz+x[i].sz;
    }
    for (i = 1; i <= n; ++i)
    {
        cout << x[i].sz << " ";
    }
    for (i = 2; i<=n; ++i)
    {
        if (x[i].sz == 0 && x[i - 1].sz != 0)
        {
            db++;
            t=true;
        }
        if (x[i].sz == 1 && x[i - 1].sz == 1 && x[i].meg == 1 && x[i - 1].meg == 2) db++;
    }
    cout << db;
    return 0;
}
/*
10 4
8 9
1 2
1 3
4 5*/
// 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
base0/50
1Hibás válasz0/03ms1880 KiB
2Futási hiba0/02ms2468 KiB
3Hibás válasz0/22ms2640 KiB
4Hibás válasz0/22ms2636 KiB
5Hibás válasz0/22ms2840 KiB
6Hibás válasz0/22ms2964 KiB
7Hibás válasz0/22ms3132 KiB
8Hibás válasz0/22ms3116 KiB
9Hibás válasz0/22ms3256 KiB
10Hibás válasz0/22ms3320 KiB
11Futási hiba0/22ms3792 KiB
12Futási hiba0/22ms3880 KiB
13Futási hiba0/32ms3620 KiB
14Futási hiba0/32ms3620 KiB
15Futási hiba0/32ms3624 KiB
16Futási hiba0/32ms3752 KiB
17Futási hiba0/32ms3980 KiB
18Futási hiba0/32ms3932 KiB
19Futási hiba0/32ms3936 KiB
20Futási hiba0/32ms4204 KiB
21Futási hiba0/32ms4192 KiB
22Futási hiba0/32ms4132 KiB