69562023-12-21 11:19:09MagyarKendeSZLGÁruszállítás üres szakaszaicpp17Accepted 50/5082ms11788 KiB
#include <iostream>
#include <map>
using namespace std;
#define speed cin.tie(0); ios::sync_with_stdio(0)

int main() {
    speed;
    
    int N, M;
    cin >> N >> M;
    map<int, int> from;

    while (M--) {
        int E, V;
        cin >> E >> V;
        from[E] = max(from[E], V);
    }
    from[N] = N;

    int result = 0, pos = 1;

    for (auto [e, v] : from) {
        if (pos >= N) break;
        if (pos < e) result++;
        pos = max(pos, v);
    }

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/082ms11004 KiB
3Accepted2/23ms2236 KiB
4Accepted2/23ms2444 KiB
5Accepted2/23ms2512 KiB
6Accepted2/23ms2596 KiB
7Accepted2/23ms2600 KiB
8Accepted2/23ms2596 KiB
9Accepted2/23ms2596 KiB
10Accepted2/23ms2880 KiB
11Accepted2/23ms2896 KiB
12Accepted2/23ms2964 KiB
13Accepted3/36ms3484 KiB
14Accepted3/38ms3716 KiB
15Accepted3/36ms3444 KiB
16Accepted3/348ms7900 KiB
17Accepted3/350ms8004 KiB
18Accepted3/357ms8548 KiB
19Accepted3/38ms3860 KiB
20Accepted3/38ms4268 KiB
21Accepted3/372ms11468 KiB
22Accepted3/376ms11788 KiB