69872023-12-23 22:12:46999Áruszállítás (75 pont)cpp17Accepted 75/7598ms22512 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
	int n,m;cin>>n>>m;
	vector<int> l(m),r(m),cnt(n+2);
	for(int i = 0;i<m;i++){
		cin>>l[i]>>r[i];
		cnt[l[i]]++;
		cnt[r[i]]--;
	}int ans=0;
	for(int i = 1;i<n;i++){
		cnt[i]+=cnt[i-1];
		if(cnt[i]==0)ans++;
	}
	cout<<ans<<endl;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1808 KiB
2Accepted0/098ms20828 KiB
3Accepted3/33ms2268 KiB
4Accepted3/33ms2516 KiB
5Accepted3/33ms2724 KiB
6Accepted3/33ms2812 KiB
7Accepted3/33ms2936 KiB
8Accepted4/43ms3120 KiB
9Accepted4/43ms3328 KiB
10Accepted4/43ms3420 KiB
11Accepted4/43ms4376 KiB
12Accepted4/44ms4928 KiB
13Accepted4/47ms5048 KiB
14Accepted4/49ms6672 KiB
15Accepted4/48ms6568 KiB
16Accepted4/49ms8648 KiB
17Accepted4/412ms10484 KiB
18Accepted4/413ms11892 KiB
19Accepted4/412ms10380 KiB
20Accepted4/414ms11780 KiB
21Accepted4/493ms22308 KiB
22Accepted4/489ms22512 KiB