21012022-12-19 13:53:58tamasmarkÁruszállítás üres szakaszaicpp17Wrong answer 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
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1880 KiB
2Runtime error0/02ms2468 KiB
3Wrong answer0/22ms2640 KiB
4Wrong answer0/22ms2636 KiB
5Wrong answer0/22ms2840 KiB
6Wrong answer0/22ms2964 KiB
7Wrong answer0/22ms3132 KiB
8Wrong answer0/22ms3116 KiB
9Wrong answer0/22ms3256 KiB
10Wrong answer0/22ms3320 KiB
11Runtime error0/22ms3792 KiB
12Runtime error0/22ms3880 KiB
13Runtime error0/32ms3620 KiB
14Runtime error0/32ms3620 KiB
15Runtime error0/32ms3624 KiB
16Runtime error0/32ms3752 KiB
17Runtime error0/32ms3980 KiB
18Runtime error0/32ms3932 KiB
19Runtime error0/32ms3936 KiB
20Runtime error0/32ms4204 KiB
21Runtime error0/32ms4192 KiB
22Runtime error0/32ms4132 KiB