138112025-01-08 19:45:45mateÁruszállítás üres szakaszaicpp17Wrong answer 2/50101ms2576 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;
			}else{
				ansp = 0;
			}
			j++;
		}
		
	}
	cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base2/50
1Accepted0/01ms316 KiB
2Wrong answer0/0101ms2468 KiB
3Wrong answer0/21ms316 KiB
4Accepted2/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms500 KiB
7Wrong answer0/21ms388 KiB
8Wrong answer0/21ms400 KiB
9Wrong answer0/21ms316 KiB
10Wrong answer0/21ms316 KiB
11Wrong answer0/21ms316 KiB
12Wrong answer0/21ms568 KiB
13Wrong answer0/36ms564 KiB
14Wrong answer0/38ms528 KiB
15Wrong answer0/36ms564 KiB
16Wrong answer0/372ms2496 KiB
17Wrong answer0/374ms2504 KiB
18Wrong answer0/385ms2576 KiB
19Wrong answer0/38ms564 KiB
20Wrong answer0/39ms564 KiB
21Wrong answer0/390ms2472 KiB
22Wrong answer0/394ms2396 KiB