216212026-01-13 17:22:13algoproÁruszállítás üres szakaszaicpp17Wrong answer 14/50100ms1144 KiB
// UUID: 15aff100-7e29-4fab-8d5e-aa136850e5c1
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m; cin >> n >> m;
	vector<int> le(m);
	vector<int> fel(m);
	for(int i = 0; i < m; i++) {
		cin >> fel[i] >> le[i];
	}
	sort(begin(le), end(le));
	sort(begin(fel), end(fel));
	int packs = 0;
	int ans = 0;
	bool x = false;
	int a = 0;
	int b = 0;
	for(int i = 0; i <m; i++) {
		if(fel[i] == 1) packs++;
		else {
			a = i;
			break;
		}
	}
	for(int i = 0; i <m; i++) {
		if(le[i] == 1) packs--;
		else {
			b = i;
			break;
		}
	}
	for(int i = 2; i<= n; i++) {
		while(a < fel.size()) {
			if(fel[a] == i) {
				a++;
				packs++;
			}
			else {
				break;
			}
		}
		while(b < le.size()) {
			if(le[b] == i) {
				b++;
				packs--;
			}
			else break;
		}
		if(packs == 0 && x == false) {
			ans++;
			x = true;
		}
		else if(packs > 0) x = false;
	}
	cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/01ms316 KiB
2Wrong answer0/0100ms1076 KiB
3Accepted2/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Accepted2/21ms500 KiB
12Accepted2/22ms316 KiB
13Wrong answer0/36ms440 KiB
14Wrong answer0/38ms316 KiB
15Wrong answer0/36ms436 KiB
16Wrong answer0/371ms1040 KiB
17Wrong answer0/374ms820 KiB
18Wrong answer0/383ms1144 KiB
19Wrong answer0/39ms316 KiB
20Wrong answer0/312ms468 KiB
21Wrong answer0/390ms1120 KiB
22Wrong answer0/394ms1076 KiB