70612023-12-29 09:19:59MagyarKendeSZLGÁruszállítás (75 pont)cpp17Accepted 75/7582ms12484 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int main() {
    speed;

    int N, M;
    cin >> N >> M;
    map<int, int> from;
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        from[a] = max(from[a], b);
    }
    from[N] = N;

    int result = 0, pos = 1;

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

    cout << result;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1828 KiB
2Accepted0/082ms11000 KiB
3Accepted3/33ms2248 KiB
4Accepted3/33ms2484 KiB
5Accepted3/33ms2696 KiB
6Accepted3/33ms2760 KiB
7Accepted3/33ms2760 KiB
8Accepted4/43ms2988 KiB
9Accepted4/43ms3072 KiB
10Accepted4/42ms3068 KiB
11Accepted4/43ms3228 KiB
12Accepted4/43ms3564 KiB
13Accepted4/46ms4292 KiB
14Accepted4/48ms4584 KiB
15Accepted4/46ms4480 KiB
16Accepted4/47ms4572 KiB
17Accepted4/47ms4524 KiB
18Accepted4/48ms4680 KiB
19Accepted4/48ms4692 KiB
20Accepted4/48ms4736 KiB
21Accepted4/472ms11984 KiB
22Accepted4/478ms12484 KiB