20152022-12-14 10:14:18gkataÁruszállítás üres szakaszaicpp17Memory limit exceeded 44/5094ms27232 KiB
#include <iostream>
//#include <fstream>
#include <vector>

using namespace std;

//ifstream cin("aru.in");
//ofstream cout("aru.out");



struct aru
{
    int vesz,lerak,arudb;
};

vector <aru> x;
int n,m,a,b,i,db;

int main()
{
    cin>>n>>m;
    x.resize(n+1);

    for(i=1;i<=m;++i)
    {
        cin>>a>>b;
        ++x[a].vesz;
        ++x[b].lerak;
    }

    x[0].arudb=1;
    for(i=1;i<=n;++i)
    {
        if(i>1) x[i].arudb=x[i-1].arudb;
        if(x[i].vesz!=0) x[i].arudb+=x[i].vesz;
        if(x[i].lerak!=0) x[i].arudb-=x[i].lerak;
        if(x[i].arudb==0 && x[i].arudb!=x[i-1].arudb && i!=n) ++db;
    }

    cout<<db;
    //for(auto &e:x) cout<<e<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base44/50
1Accepted0/03ms1896 KiB
2Accepted0/094ms25496 KiB
3Accepted2/22ms2324 KiB
4Accepted2/22ms2428 KiB
5Accepted2/22ms2580 KiB
6Accepted2/22ms2616 KiB
7Accepted2/22ms2744 KiB
8Accepted2/22ms2984 KiB
9Accepted2/22ms3188 KiB
10Accepted2/22ms3272 KiB
11Accepted2/23ms4448 KiB
12Accepted2/24ms5352 KiB
13Accepted3/37ms5560 KiB
14Accepted3/39ms7584 KiB
15Accepted3/38ms7584 KiB
16Accepted3/371ms27232 KiB
17Accepted3/370ms27140 KiB
18Accepted3/378ms27028 KiB
19Accepted3/313ms13148 KiB
20Accepted3/316ms15552 KiB
21Memory limit exceeded0/32ms3772 KiB
22Memory limit exceeded0/32ms3824 KiB