19742022-12-12 19:02:501478Áruszállítás üres szakaszaicpp11Wrong answer 34/5087ms11976 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
base34/50
1Accepted0/03ms1812 KiB
2Accepted0/087ms9728 KiB
3Wrong answer0/22ms2208 KiB
4Wrong answer0/22ms2416 KiB
5Wrong answer0/22ms2488 KiB
6Wrong answer0/22ms2612 KiB
7Wrong answer0/22ms2820 KiB
8Wrong answer0/22ms3028 KiB
9Accepted2/22ms3128 KiB
10Accepted2/22ms3232 KiB
11Wrong answer0/22ms3496 KiB
12Wrong answer0/23ms4168 KiB
13Accepted3/37ms4308 KiB
14Accepted3/38ms4884 KiB
15Accepted3/36ms4880 KiB
16Accepted3/361ms11512 KiB
17Accepted3/364ms11712 KiB
18Accepted3/371ms11660 KiB
19Accepted3/39ms7004 KiB
20Accepted3/310ms7892 KiB
21Accepted3/379ms11788 KiB
22Accepted3/379ms11976 KiB