20142022-12-14 10:13:12gkataÁruszállítás üres szakaszaicpp17Wrong answer 0/503ms4484 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/03ms1932 KiB
2Wrong answer0/02ms2184 KiB
3Wrong answer0/22ms2428 KiB
4Wrong answer0/22ms2648 KiB
5Wrong answer0/22ms2848 KiB
6Wrong answer0/22ms3056 KiB
7Wrong answer0/22ms3088 KiB
8Wrong answer0/22ms3284 KiB
9Wrong answer0/22ms3244 KiB
10Wrong answer0/22ms3376 KiB
11Wrong answer0/22ms3580 KiB
12Wrong answer0/22ms3804 KiB
13Wrong answer0/32ms3876 KiB
14Wrong answer0/32ms4004 KiB
15Wrong answer0/32ms3920 KiB
16Wrong answer0/32ms4156 KiB
17Wrong answer0/32ms4296 KiB
18Wrong answer0/32ms4248 KiB
19Wrong answer0/32ms4348 KiB
20Wrong answer0/32ms4348 KiB
21Wrong answer0/32ms4484 KiB
22Wrong answer0/32ms4456 KiB