64672023-12-02 17:51:26xxxÁruszállítás üres szakaszaicpp14Wrong answer 34/5081ms12420 KiB
#include <bits/stdc++.h>
using namespace std;

const int mxN = 1e6;

int trip[mxN+2];

int main() {
	int n, m;
	cin >> n >> m;
	for(int i  = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		trip[x]++;
		trip[y]--;
	}
	for(int i = 1; i <= n; i++) {
		trip[i] += trip[i-1];
	}

	bool now = false;
	int ans = 0;

	for(int i = 1; i <= n; i++) {
		//cout << trip[i] << ' ';
		if (trip[i] == 0 && !now) {
			now = true;
			ans++;
		} else if (trip[i] != 0) {
			now = false;
		}
	}



	if (trip[1] != 0) cout << ans << '\n';
	else cout << ans-1 << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/03ms1876 KiB
2Accepted0/081ms9996 KiB
3Wrong answer0/23ms2280 KiB
4Wrong answer0/23ms2496 KiB
5Wrong answer0/22ms2604 KiB
6Wrong answer0/23ms2808 KiB
7Wrong answer0/23ms2892 KiB
8Wrong answer0/23ms3128 KiB
9Accepted2/23ms3232 KiB
10Accepted2/23ms3440 KiB
11Wrong answer0/23ms4020 KiB
12Wrong answer0/23ms4264 KiB
13Accepted3/37ms4416 KiB
14Accepted3/38ms5212 KiB
15Accepted3/37ms5440 KiB
16Accepted3/367ms11640 KiB
17Accepted3/367ms11932 KiB
18Accepted3/375ms11940 KiB
19Accepted3/310ms7464 KiB
20Accepted3/313ms8188 KiB
21Accepted3/375ms12420 KiB
22Accepted3/376ms12264 KiB