64712023-12-02 17:58:25xxxÁruszállítás üres szakaszaicpp14Accepted 50/5081ms11928 KiB
#include <bits/stdc++.h>
using namespace std;

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

	bool now = false;
	int ans = 0;

	for(int i = 2; i < n; i++) {
		if (trip[i-1] != 0 && trip[i] == 0) {
			ans++;
		}
	}



	if (trip[1] != 0) cout << ans << '\n';
	else cout << ans+1 << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1680 KiB
2Accepted0/081ms9652 KiB
3Accepted2/23ms2140 KiB
4Accepted2/23ms2148 KiB
5Accepted2/23ms2140 KiB
6Accepted2/23ms2268 KiB
7Accepted2/23ms2480 KiB
8Accepted2/23ms2728 KiB
9Accepted2/23ms2816 KiB
10Accepted2/23ms2908 KiB
11Accepted2/23ms3464 KiB
12Accepted2/23ms3908 KiB
13Accepted3/37ms3792 KiB
14Accepted3/38ms4444 KiB
15Accepted3/37ms4704 KiB
16Accepted3/364ms11104 KiB
17Accepted3/364ms11356 KiB
18Accepted3/378ms11312 KiB
19Accepted3/310ms6904 KiB
20Accepted3/313ms7812 KiB
21Accepted3/375ms11716 KiB
22Accepted3/379ms11928 KiB