19712022-12-12 18:55:211478Áruszállítás üres szakaszaicpp11Wrong answer 34/5079ms12280 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 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/03ms1996 KiB
2Accepted0/079ms9732 KiB
3Wrong answer0/22ms2172 KiB
4Wrong answer0/22ms2376 KiB
5Wrong answer0/22ms2628 KiB
6Wrong answer0/22ms2664 KiB
7Wrong answer0/22ms2784 KiB
8Wrong answer0/22ms2860 KiB
9Accepted2/22ms2864 KiB
10Accepted2/22ms2996 KiB
11Wrong answer0/22ms3512 KiB
12Wrong answer0/23ms4232 KiB
13Accepted3/36ms4140 KiB
14Accepted3/38ms4940 KiB
15Accepted3/36ms5144 KiB
16Accepted3/361ms11716 KiB
17Accepted3/363ms11944 KiB
18Accepted3/371ms11868 KiB
19Accepted3/38ms7352 KiB
20Accepted3/310ms8388 KiB
21Accepted3/374ms12172 KiB
22Accepted3/376ms12280 KiB