19732022-12-12 19:02:021478Áruszállítás üres szakaszaicpp11Runtime error 0/504ms4288 KiB
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 

int main()
{
    ifstream cin("be.txt");

    /*
    int n; cin>>n;
    vector<int> a(n+1);
    multiset<int> s;
    for(int i=1; i<=n; i++){
        cin>>a[i];
        s.insert(a[i]);
    }
    for(int i=1; i<=n; i++){
        s.erase(s.lower_bound(a[i]));
        if(!s.count(a[i])){
            cout<<i;
            break;
        }
    }*/

    //aruszallitas ures szakaszai
    int n;
    cin>>n;
    vector<int> a(n+1);
    int m;
    cin>>m;
    while(m){
        int k, v;
        cin>>k>>v;
        a[k]++;
        a[v]--;
        m--;
    }
    a[0] = 1000001;
    int sum = 0, ans = 0;
    for(int i=1; i<=n; i++){
        //cout<<a[i]<<" ";
        sum += a[i];
        if(sum - a[i] != 0 && sum == 0) ans++;
    }

    cout<<ans;
    
 
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Runtime error0/04ms2156 KiB
2Runtime error0/04ms2348 KiB
3Runtime error0/24ms2696 KiB
4Runtime error0/24ms2792 KiB
5Runtime error0/24ms3036 KiB
6Runtime error0/24ms3364 KiB
7Runtime error0/24ms3560 KiB
8Runtime error0/24ms3468 KiB
9Runtime error0/24ms3468 KiB
10Runtime error0/24ms3716 KiB
11Runtime error0/24ms3724 KiB
12Runtime error0/24ms3668 KiB
13Runtime error0/34ms3872 KiB
14Runtime error0/34ms3836 KiB
15Runtime error0/34ms3964 KiB
16Runtime error0/34ms4044 KiB
17Runtime error0/34ms4052 KiB
18Runtime error0/34ms3952 KiB
19Runtime error0/34ms3948 KiB
20Runtime error0/34ms4288 KiB
21Runtime error0/34ms4276 KiB
22Runtime error0/34ms4236 KiB