138102025-01-08 19:42:57mateÁruszállítás üres szakaszaicpp17Wrong answer 2/50107ms2572 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,m; cin >> n >> m;
	vector <pair <int,int>> v;
	for(int i = 0; i < m; i++){
		int a,b; cin >> a >> b;
		v.push_back({a,1});
		v.push_back({b,2});
	}
	sort(v.begin(),v.end());
	/*for(auto x : v){
		cout << x.first << ' ' << x.second << '\n';
	}*/
	//vector <int> szumma(n+1,0);
	int cnt = 0;
	int ans = 0;
	bool ansp = 0;
	int j = 0;
	for(int i = 1; i <= n; i++){
		if(ansp){
			ans++;
			ansp = 0;
		}
		while(i == v[j].first){
			if(v[j].second == 1){
				cnt++;
			}
			if(v[j].second == 2){
				cnt--;
			}
			if(cnt == 0){
				//ans++;
				ansp = 1;
			}
			j++;
		}
		
	}
	cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms316 KiB
2Wrong answer0/0107ms2572 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms364 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/21ms316 KiB
13Wrong answer0/37ms628 KiB
14Wrong answer0/38ms524 KiB
15Wrong answer0/36ms760 KiB
16Wrong answer0/378ms2532 KiB
17Wrong answer0/378ms2512 KiB
18Wrong answer0/389ms2508 KiB
19Wrong answer0/39ms756 KiB
20Wrong answer0/310ms564 KiB
21Wrong answer0/398ms2476 KiB
22Wrong answer0/3100ms2528 KiB