64652023-12-02 17:49:12xxxÁruszállítás üres szakaszaicpp14Wrong answer 0/5079ms12308 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;
		}
	}

	cout << ans+1 << '\n';

}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/03ms1876 KiB
2Wrong answer0/079ms9988 KiB
3Wrong answer0/23ms2280 KiB
4Wrong answer0/23ms2492 KiB
5Wrong answer0/23ms2632 KiB
6Wrong answer0/23ms2704 KiB
7Wrong answer0/23ms2808 KiB
8Wrong answer0/23ms3016 KiB
9Wrong answer0/23ms3228 KiB
10Wrong answer0/23ms3440 KiB
11Wrong answer0/23ms4168 KiB
12Wrong answer0/23ms4352 KiB
13Wrong answer0/37ms4356 KiB
14Wrong answer0/38ms5348 KiB
15Wrong answer0/37ms5840 KiB
16Wrong answer0/365ms12240 KiB
17Wrong answer0/367ms12152 KiB
18Wrong answer0/374ms12148 KiB
19Wrong answer0/310ms7436 KiB
20Wrong answer0/312ms8132 KiB
21Wrong answer0/374ms12012 KiB
22Wrong answer0/375ms12308 KiB