124342024-12-17 19:29:54szabelrÁruszállítás üres szakaszaicpp17Accepted 50/5092ms4320 KiB
#include <iostream>

using namespace std;
int aru[1000001]{ 0 };
int main()
{
    long long n, m, db=0;
    cin >> n >> m;
    int x, y;
    aru[n] = 1;

    for (int i = 1; i <= m; i++) {
        cin >> x >> y;
        aru[x]++;
        aru[y]--;
    }
    for (int i = 1; i <= n; i++) {
        aru[i] = aru[i] + aru[i - 1];
    }
    for (int i = 1; i <= n; i++) {
        if (aru[i] == 0 and aru[i + 1] != 0) {
            db++;
        }
    }
    cout << db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/092ms4320 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted2/21ms320 KiB
9Accepted2/21ms320 KiB
10Accepted2/21ms320 KiB
11Accepted2/21ms568 KiB
12Accepted2/21ms568 KiB
13Accepted3/34ms568 KiB
14Accepted3/37ms1080 KiB
15Accepted3/34ms1076 KiB
16Accepted3/364ms4144 KiB
17Accepted3/367ms4148 KiB
18Accepted3/375ms4092 KiB
19Accepted3/38ms1980 KiB
20Accepted3/39ms2372 KiB
21Accepted3/379ms4316 KiB
22Accepted3/376ms4312 KiB