20132022-12-14 10:12:02gkataÁruszállítás üres szakaszaicpp17Wrong answer 0/503ms4196 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
base0/50
1Wrong answer0/03ms1928 KiB
2Wrong answer0/02ms2120 KiB
3Wrong answer0/22ms2332 KiB
4Wrong answer0/22ms2584 KiB
5Wrong answer0/22ms2792 KiB
6Wrong answer0/23ms3044 KiB
7Wrong answer0/22ms3020 KiB
8Wrong answer0/22ms3076 KiB
9Wrong answer0/22ms3204 KiB
10Wrong answer0/22ms3416 KiB
11Wrong answer0/22ms3444 KiB
12Wrong answer0/22ms3496 KiB
13Wrong answer0/32ms3448 KiB
14Wrong answer0/32ms3452 KiB
15Wrong answer0/32ms3448 KiB
16Wrong answer0/32ms3452 KiB
17Wrong answer0/32ms3480 KiB
18Wrong answer0/32ms3708 KiB
19Wrong answer0/32ms3788 KiB
20Wrong answer0/32ms3916 KiB
21Wrong answer0/32ms4124 KiB
22Wrong answer0/32ms4196 KiB