64642023-12-02 17:45:12xxxÁruszállítás üres szakaszaicpp14Wrong answer 14/5079ms12396 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++) {
		if (trip[i] == 0 && !now) {
			now = true;
			ans++;
		} else if (trip[i] != 0) {
			now = false;
		}
	}

	cout << ans << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/03ms1876 KiB
2Wrong answer0/079ms9988 KiB
3Accepted2/22ms2208 KiB
4Wrong answer0/22ms2156 KiB
5Accepted2/23ms2280 KiB
6Accepted2/23ms2496 KiB
7Accepted2/23ms2728 KiB
8Accepted2/23ms2920 KiB
9Wrong answer0/23ms3156 KiB
10Wrong answer0/23ms3404 KiB
11Accepted2/23ms3820 KiB
12Accepted2/23ms4332 KiB
13Wrong answer0/37ms4540 KiB
14Wrong answer0/38ms5460 KiB
15Wrong answer0/37ms5420 KiB
16Wrong answer0/364ms12060 KiB
17Wrong answer0/365ms12232 KiB
18Wrong answer0/374ms12280 KiB
19Wrong answer0/310ms7468 KiB
20Wrong answer0/312ms8332 KiB
21Wrong answer0/374ms12396 KiB
22Wrong answer0/376ms12192 KiB