214422026-01-13 08:58:56algoproÁruszállítás üres szakaszaicpp17Wrong answer 14/5087ms4328 KiB
// UUID: ad1bd2c9-73c1-4dfd-8a10-b608c885fa5d
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;

	vector<int> diffs(n+1, 0);
	for (int i=0;i<m;i++){
		int start, end;
		cin >> start >> end;
		diffs[start]++;
		diffs[end]--;
	}
	// for(int d:diffs){
	// 	cout << d << " ";
	// }
	// cout << "\n";

	int empty_section_count = 0;
	int total = 0;
	for(int i=0;i<=n;i++){
		total += diffs[i];
		if(total==0){ // found the beginning of an empty section
			empty_section_count++;
			while(i<n && total == 0){
				i++;
				total += diffs[i];
			}
		}
	}
	cout << (diffs[1] == 0 ? empty_section_count : empty_section_count -1);
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/01ms316 KiB
2Wrong answer0/087ms4148 KiB
3Accepted2/21ms500 KiB
4Wrong answer0/21ms332 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Accepted2/21ms564 KiB
12Accepted2/22ms564 KiB
13Wrong answer0/34ms564 KiB
14Wrong answer0/37ms1128 KiB
15Wrong answer0/34ms1132 KiB
16Wrong answer0/363ms4324 KiB
17Wrong answer0/361ms4328 KiB
18Wrong answer0/370ms4148 KiB
19Wrong answer0/38ms1976 KiB
20Wrong answer0/39ms2364 KiB
21Wrong answer0/375ms4324 KiB
22Wrong answer0/376ms4148 KiB