138082025-01-08 19:36:27mateÁruszállítás üres szakaszaicpp17Wrong answer 34/50101ms2472 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;
	int j = 0;
	for(int i = 1; i <= n; i++){
		while(i == v[j].first){
			if(v[j].second == 1){
				cnt++;
			}
			if(v[j].second == 2){
				cnt--;
				if(cnt == 0){
					ans++;
				}
			}
			j++;
		}
	}
	cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base34/50
1Accepted0/01ms508 KiB
2Accepted0/0101ms2464 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Wrong answer0/21ms316 KiB
9Accepted2/21ms316 KiB
10Accepted2/21ms316 KiB
11Wrong answer0/21ms400 KiB
12Wrong answer0/21ms316 KiB
13Accepted3/36ms464 KiB
14Accepted3/38ms620 KiB
15Accepted3/36ms564 KiB
16Accepted3/372ms2360 KiB
17Accepted3/374ms2468 KiB
18Accepted3/385ms2468 KiB
19Accepted3/38ms564 KiB
20Accepted3/310ms704 KiB
21Accepted3/392ms2472 KiB
22Accepted3/394ms2472 KiB