20002022-12-13 15:29:19szabel26Áruszállítás üres szakaszaicpp17Accepted 50/5090ms27548 KiB
#include <iostream>
#include <vector>
using namespace std;

struct szallit{
    int fel,le,adb;
};

int i,n,m,a,b,adb,db;

vector<szallit>x;

int main()
{
    cin>>n>>m;
    x.resize(n+1);
    for(i=1;i<=m;++i)
    {
        cin>>a>>b;
        ++x[a].fel;
        ++x[b].le;
    }
    x[0].adb=1;
    for(i=1;i<=n;++i)
    {
        if(i>1) x[i].adb=x[i-1].adb;
        if(x[i].fel!=0)x[i].adb+=x[i].fel;
        if(x[i].le!=0)x[i].adb-=x[i].le;
        if(x[i].adb==0 && x[i].adb!=x[i-1].adb && i!=n) ++db;
    }
    cout<<db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1876 KiB
2Accepted0/090ms25564 KiB
3Accepted2/22ms2200 KiB
4Accepted2/22ms2404 KiB
5Accepted2/22ms2604 KiB
6Accepted2/22ms2816 KiB
7Accepted2/22ms3016 KiB
8Accepted2/22ms3224 KiB
9Accepted2/22ms3420 KiB
10Accepted2/22ms3508 KiB
11Accepted2/23ms4872 KiB
12Accepted2/23ms5432 KiB
13Accepted3/37ms5432 KiB
14Accepted3/39ms7772 KiB
15Accepted3/38ms7896 KiB
16Accepted3/371ms27140 KiB
17Accepted3/371ms27424 KiB
18Accepted3/379ms27404 KiB
19Accepted3/313ms13200 KiB
20Accepted3/314ms15456 KiB
21Accepted3/382ms27548 KiB
22Accepted3/385ms27492 KiB