209902026-01-11 23:15:31hunzombiÁruszállítás üres szakaszaicpp17Wrong answer 2/5032ms4172 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<int> vec(n + 2, 0);
    for (int i=0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        vec[u]++; vec[v]--;
    }
    bool in_empty = true;
    long long cnt = 0;
    int ans = 0;
    for (int i=1; i < n; i++) {
        cnt += vec[i];
        if (cnt == 0) {
            if (!in_empty) {
                ans++;
                in_empty = true;
            }
        } else {
            in_empty = false;
        }
    }
    cout << ans << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms508 KiB
2Wrong answer0/030ms4172 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/22ms564 KiB
12Wrong answer0/21ms564 KiB
13Wrong answer0/33ms568 KiB
14Wrong answer0/34ms1076 KiB
15Wrong answer0/33ms1076 KiB
16Wrong answer0/321ms4148 KiB
17Wrong answer0/323ms4148 KiB
18Wrong answer0/326ms4148 KiB
19Wrong answer0/34ms2036 KiB
20Wrong answer0/34ms2356 KiB
21Wrong answer0/332ms4148 KiB
22Wrong answer0/330ms4148 KiB