19752022-12-12 19:09:041478Áruszállítás üres szakaszaicpp11Accepted 50/5082ms11248 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--;
    }
    int ans = 0;
    for (int i = 2; i < n; i++)
    {
        a[i] += a[i - 1];
        if (a[i - 1] != 0 && a[i] == 0)
            ans++;
    }
    if (a[1] == 0)
        ans++;

    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1836 KiB
2Accepted0/081ms9616 KiB
3Accepted2/22ms2088 KiB
4Accepted2/22ms2164 KiB
5Accepted2/22ms2404 KiB
6Accepted2/22ms2348 KiB
7Accepted2/22ms2348 KiB
8Accepted2/22ms2344 KiB
9Accepted2/22ms2344 KiB
10Accepted2/22ms2472 KiB
11Accepted2/22ms2736 KiB
12Accepted2/23ms3128 KiB
13Accepted3/37ms3380 KiB
14Accepted3/38ms4240 KiB
15Accepted3/36ms4184 KiB
16Accepted3/361ms10812 KiB
17Accepted3/364ms11012 KiB
18Accepted3/372ms10960 KiB
19Accepted3/310ms6560 KiB
20Accepted3/312ms7536 KiB
21Accepted3/376ms11248 KiB
22Accepted3/382ms11248 KiB