33112023-02-25 08:24:15horvathabelÁruszállítás üres szakaszaicpp17Wrong answer 6/5078ms11872 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin>>n>>m;
	vector<int> kom;
	kom.assign(n+1,0);
	for (int i=0; i<m;i++){
		int x,y;
		cin>>x>>y; 
		kom[x]=1;
		kom[y]=-1;
	}
	bool voltemar; 
	int ans=0; 
	int ossz=0; 
	for (int i=1; i<=n;i++){
		ossz+=kom[i];
		if (ossz==0 && !voltemar){
			ans++; 
			voltemar=true;
		}
		if (ossz!=0 && voltemar){
			voltemar=false; 
		}
	}
	cout<<ans; 
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Accepted0/03ms1812 KiB
2Wrong answer0/078ms9776 KiB
3Accepted2/23ms2228 KiB
4Wrong answer0/23ms2476 KiB
5Wrong answer0/22ms2528 KiB
6Wrong answer0/22ms2528 KiB
7Accepted2/23ms2672 KiB
8Wrong answer0/23ms2756 KiB
9Wrong answer0/23ms3000 KiB
10Wrong answer0/23ms3216 KiB
11Accepted2/23ms3580 KiB
12Wrong answer0/23ms3844 KiB
13Wrong answer0/37ms3844 KiB
14Wrong answer0/38ms4872 KiB
15Wrong answer0/37ms5080 KiB
16Wrong answer0/363ms11660 KiB
17Wrong answer0/363ms11616 KiB
18Wrong answer0/371ms11872 KiB
19Wrong answer0/39ms7104 KiB
20Wrong answer0/310ms8084 KiB
21Wrong answer0/374ms11708 KiB
22Wrong answer0/375ms11704 KiB