64662023-12-02 17:49:38xxxÁruszállítás üres szakaszaicpp14Wrong answer 36/5079ms12144 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
base36/50
1Wrong answer0/03ms1876 KiB
2Accepted0/079ms9932 KiB
3Wrong answer0/23ms2348 KiB
4Accepted2/23ms2504 KiB
5Wrong answer0/23ms2728 KiB
6Wrong answer0/23ms2936 KiB
7Wrong answer0/23ms3144 KiB
8Wrong answer0/23ms3228 KiB
9Accepted2/23ms3200 KiB
10Accepted2/23ms3328 KiB
11Wrong answer0/23ms3768 KiB
12Wrong answer0/23ms4024 KiB
13Accepted3/37ms4032 KiB
14Accepted3/38ms5020 KiB
15Accepted3/37ms4984 KiB
16Accepted3/364ms11648 KiB
17Accepted3/365ms11836 KiB
18Accepted3/374ms11788 KiB
19Accepted3/310ms7156 KiB
20Accepted3/312ms8076 KiB
21Accepted3/372ms11856 KiB
22Accepted3/375ms12144 KiB