214762026-01-13 10:09:12algoproÁruszállítás üres szakaszaicpp17Wrong answer 0/50312ms16104 KiB
// UUID: a8f87c89-b052-405a-be20-709708e4489d
#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";

	if(m==1){
		cout << (diffs[1] == 0 ? 1 : 0);
		return 0;
	}

	vector<int> totals(n+1, 0);
	
	totals[1] = diffs[1];
	
	for(int i=2;i<=n;i++){
		totals[i] = totals[i-1] + diffs[i];
	}
	for(int t:totals){
		cout << t << " ";
	}
	cout << "\n";

	int empty_section_count = 0;

	int previous;
	int current = totals[0];
	for(int i=1;i<=n;i++){
		previous = current;
		current = totals[i];

		if(previous == 0 && current ==0){
			continue;
		}else if(previous == 0 && current != 0){
			continue;
		}else if(previous != 0 && current == 0){
			empty_section_count++;
		}else{  // previous != 0 && current != 0
			continue;
		}



	}
	cout << empty_section_count;



	// for(int i=0;i<=n;i++){
	// 	if (totals[i]==0){
	// 		empty_section_count++;
	// 		while(i<n && totals[i]==0){
	// 			i++;
	// 		}
	// 	}
	// }

	// cout << (totals[1] == 0 ? empty_section_count: empty_section_count - 1);
}
SubtaskSumTestVerdictTimeMemory
base0/50
1Wrong answer0/01ms316 KiB
2Time limit exceeded0/0312ms12780 KiB
3Wrong answer0/21ms508 KiB
4Wrong answer0/21ms500 KiB
5Wrong answer0/21ms332 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms508 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/214ms1076 KiB
12Wrong answer0/223ms1372 KiB
13Wrong answer0/326ms1360 KiB
14Wrong answer0/348ms2580 KiB
15Wrong answer0/346ms2508 KiB
16Wrong answer0/3298ms15080 KiB
17Time limit exceeded0/3300ms15156 KiB
18Time limit exceeded0/3310ms16104 KiB
19Wrong answer0/398ms4916 KiB
20Wrong answer0/3123ms6192 KiB
21Time limit exceeded0/3307ms12596 KiB
22Time limit exceeded0/3307ms12772 KiB