29002023-02-02 12:50:25tamasmarkÁruszállítás üres szakaszaicpp17Wrong answer 2/50115ms36684 KiB
// arulas ures szakaszai.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

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

using namespace std;

struct adat
{
    long long indul, erkezik;
};
deque<adat >x;
long long i, n,a,b,m,db;
bool t;

int main()
{
    cin >> n>>m;
    x.resize(n + 1);
    for (i = 1; i <= m; ++i)
    {
        cin >> a >> b;
        x[a].indul++;
        x[b].erkezik++;
    }
    //x[1].erkezik = x[1].indul;
    for (i = 2; i <=n; ++i)
    {
        if (x[i].erkezik == 0)
        {
            x[i].indul =x[i].indul + x[i - 1].indul;
        }
        else if (x[i].erkezik)
        {
            x[i].indul = x[i].indul + (x[i - 1].indul-x[i].erkezik);
        }
        if (x[i].indul == 0&&x[i-1].indul>0&&i<n)
        {
            db++;
            t = true;
        }
        /*else if (t && x[i].indul)
        {
            t = true;
        }*/
        
    }
    cout << db;
    
    return 0;
}
/*
10 4
8 9
1 6
1 3
3 4
*/
// 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
base2/50
1Accepted0/03ms1680 KiB
2Wrong answer0/0115ms34472 KiB
3Wrong answer0/23ms2160 KiB
4Accepted2/23ms2312 KiB
5Wrong answer0/22ms2384 KiB
6Wrong answer0/23ms2524 KiB
7Wrong answer0/22ms2624 KiB
8Wrong answer0/22ms2596 KiB
9Wrong answer0/23ms2816 KiB
10Wrong answer0/23ms3032 KiB
11Wrong answer0/24ms5412 KiB
12Wrong answer0/24ms6448 KiB
13Wrong answer0/38ms6460 KiB
14Wrong answer0/313ms9288 KiB
15Wrong answer0/310ms9372 KiB
16Wrong answer0/386ms35964 KiB
17Wrong answer0/387ms35972 KiB
18Wrong answer0/398ms35932 KiB
19Wrong answer0/318ms16828 KiB
20Wrong answer0/320ms20336 KiB
21Wrong answer0/3107ms36616 KiB
22Wrong answer0/3109ms36684 KiB