124352024-12-17 19:30:41szabelrÁruszállítás üres szakaszaicpp17Accepted 50/5082ms4316 KiB
#include <iostream>

using namespace std;
int aru[1000001]{ 0 };
int main()
{
    int 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/082ms4152 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/22ms756 KiB
13Accepted3/34ms568 KiB
14Accepted3/37ms1132 KiB
15Accepted3/34ms1136 KiB
16Accepted3/361ms4108 KiB
17Accepted3/364ms4200 KiB
18Accepted3/371ms4148 KiB
19Accepted3/38ms1848 KiB
20Accepted3/39ms2360 KiB
21Accepted3/374ms4316 KiB
22Accepted3/371ms4316 KiB