144132025-01-10 18:19:17VarszegiLeventeÁruszállítás üres szakaszaicpp17Wrong answer 2/5096ms8240 KiB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
/*
10 4
8 9
1 6
1 3
3 4
*/
int main()
{
    int n, q; cin >> n >> q;
    vector<int> delta(n + 1, 0);
    for(int i = 0; i < q; i++){
        int a, b; cin >> a >> b;
        delta[a]++;
        delta[b]--;
    }
    delta[0] = 1;
    int counter = 0;
    vector<int> packs(n + 1, 0);
    for(int i = 1; i <= n; i++){
        packs[i] = packs[i - 1] + delta[i];
    }
    for(int i = 1; i <= n - 1; i++){
        if(packs[i] == 0 and packs[i - 1] != 0){
            counter++;
        }
    }
    cout << counter;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms500 KiB
2Wrong answer0/096ms8240 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/21ms820 KiB
12Wrong answer0/22ms1088 KiB
13Wrong answer0/36ms1028 KiB
14Wrong answer0/38ms1844 KiB
15Wrong answer0/36ms1644 KiB
16Wrong answer0/365ms8160 KiB
17Wrong answer0/367ms8160 KiB
18Wrong answer0/378ms7988 KiB
19Wrong answer0/310ms3380 KiB
20Wrong answer0/312ms4160 KiB
21Wrong answer0/379ms8236 KiB
22Wrong answer0/379ms8156 KiB