209862026-01-11 23:10:24hunzombiÁruszállítás üres szakaszaicpp17Wrong answer 14/5030ms4292 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 = 0;
    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
base14/50
1Accepted0/01ms316 KiB
2Wrong answer0/030ms4164 KiB
3Accepted2/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Wrong answer0/21ms544 KiB
10Wrong answer0/21ms316 KiB
11Accepted2/22ms564 KiB
12Accepted2/22ms564 KiB
13Wrong answer0/33ms760 KiB
14Wrong answer0/34ms1092 KiB
15Wrong answer0/33ms1076 KiB
16Wrong answer0/321ms4148 KiB
17Wrong answer0/323ms4148 KiB
18Wrong answer0/325ms4140 KiB
19Wrong answer0/34ms1844 KiB
20Wrong answer0/34ms2312 KiB
21Wrong answer0/328ms4148 KiB
22Wrong answer0/327ms4292 KiB