220542026-01-14 16:33:37algoproÁruszállítás üres szakaszaicpp17Accepted 50/5092ms4328 KiB
// UUID: 2a7df7d9-6672-4a78-9c87-64a1fa7b3307
//AB
//Feladat linkje: 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> allomasok(n+1, 0);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        allomasok[a] += +1;
        allomasok[b] -= 1;
        //for (int x : allomasok) cout << x << " ";cout << "\n";
    }
    int akt = allomasok[0];
    //for (int x : allomasok) cout << x << " ";
    int eures=false;
    int db = 0;
    for (int i = 1; i < n; i++) {
        akt += allomasok[i];
        if (akt == 0) {
            if (eures == false) {
                db++;
                //cout << "db jön! igen! figyejjé má!!!\n";
                eures = true;
            }
        } else eures = false;
        //cout << i << " | " << akt << "\n";
    }
	cout << db <<"\n";
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/092ms4148 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms508 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted2/21ms316 KiB
10Accepted2/21ms316 KiB
11Accepted2/21ms564 KiB
12Accepted2/21ms564 KiB
13Accepted3/34ms616 KiB
14Accepted3/38ms1260 KiB
15Accepted3/34ms1136 KiB
16Accepted3/361ms4228 KiB
17Accepted3/363ms4328 KiB
18Accepted3/372ms4320 KiB
19Accepted3/38ms1844 KiB
20Accepted3/39ms2376 KiB
21Accepted3/374ms4148 KiB
22Accepted3/386ms4324 KiB