75222024-01-09 13:23:12TuruTamasÁruszállítás üres szakaszaicpp17Wrong answer 14/5082ms19300 KiB
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <iostream>

using namespace std;

typedef long long ll;

ll N, M, a, b, r, valsum;
ll tomb[1000000];

int main()
{
    cin >> N >> M;
    for (ll m = 0; m < M; m++) {
        cin >> a >> b;
        a--; b--;
        tomb[a]++;
        tomb[b]--;
    }
    bool f = false;
    for (ll n = 0; n < N; n++) {
        valsum += tomb[n];
        if (valsum == 0 && !f) {
            r++;
            f = true;
        }
        else if (tomb[n] != 0) {
            f = false;
        }
    }
    cout << r << endl;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/03ms1876 KiB
2Wrong answer0/082ms17684 KiB
3Accepted2/23ms2296 KiB
4Wrong answer0/23ms2496 KiB
5Accepted2/23ms2608 KiB
6Accepted2/23ms2832 KiB
7Accepted2/23ms2812 KiB
8Accepted2/23ms3028 KiB
9Wrong answer0/23ms2996 KiB
10Wrong answer0/23ms2976 KiB
11Accepted2/23ms3580 KiB
12Accepted2/23ms4656 KiB
13Wrong answer0/37ms4856 KiB
14Wrong answer0/38ms6428 KiB
15Wrong answer0/37ms6232 KiB
16Wrong answer0/361ms4716 KiB
17Wrong answer0/363ms4872 KiB
18Wrong answer0/371ms4928 KiB
19Wrong answer0/310ms9704 KiB
20Wrong answer0/312ms11248 KiB
21Wrong answer0/375ms19300 KiB
22Wrong answer0/381ms19236 KiB