8162022-01-17 07:11:10Halasz EszterÁruszállítás üres szakaszaicpp11Runtime error 0/50118ms63420 KiB
#include <iostream>
//#include <fstream>
#include <vector>
#include <algorithm>

#define ll long long
using namespace std;

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

vector<pair<ll,ll> >x;

ll i,a,b,n,m,db,k,aa,bb,c,d;

ll has(pair<ll,ll> a, pair<ll,ll>b)
{
    if(a.first>b.first) return 0;
    else return 1;

}
ll leker(ll a,ll b,ll c,ll d)
{
    if(c<=b)
    {
        aa=min(a,c);
        bb=max(b,d);
    }
    else
    {
        aa=-1;
        bb=-1;
    }
}
int main()
{
    cin>>m>>n;
    x.resize(n+1);
    for(i=1;i<=n;++i)
    {
        cin>>a>>b;
        x[i]={a,b};
    }

    sort(x.begin()+1,x.end(),has);


    aa=x[1].first;
    bb=x[1].second;
    x.push_back({m,m});
    if(aa!=1) db++;
    for(i=2;i<=n+1;++i)
    {
        leker(aa,bb,x[i].first,x[i].second);
        if(aa==-1 && bb==-1)
        {
            db++;
            aa=x[i].first;
            bb=x[i].second;

        }
        else
        {
            a=aa;
            b=bb;
        }

    }
   // if(b<m) db++;
    cout<<db;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/048ms61816 KiB
2Runtime error0/0118ms60156 KiB
3Runtime error0/246ms63284 KiB
4Runtime error0/235ms63368 KiB
5Runtime error0/232ms63372 KiB
6Runtime error0/235ms63348 KiB
7Runtime error0/230ms63380 KiB
8Runtime error0/230ms63384 KiB
9Runtime error0/232ms63384 KiB
10Runtime error0/243ms63388 KiB
11Runtime error0/239ms63400 KiB
12Runtime error0/232ms63420 KiB
13Runtime error0/346ms63336 KiB
14Runtime error0/343ms63412 KiB
15Runtime error0/341ms63416 KiB
16Runtime error0/392ms62228 KiB
17Runtime error0/3100ms62204 KiB
18Runtime error0/3104ms62032 KiB
19Runtime error0/346ms63368 KiB
20Runtime error0/339ms63348 KiB
21Runtime error0/397ms62052 KiB
22Runtime error0/3115ms62024 KiB