64462023-11-30 15:49:25gergomiszoriÁruszállítás üres szakaszaicpp17Wrong answer 14/50103ms35088 KiB
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define endl "\n"
#define pll pair<ll,ll>
#define fs first
#define sc second 
 
void solve()
{
	ll n, m;
	cin >> n >> m;
	vector<ll> a(n), b(n);
	for(ll i = 0; i < m; i++) cin >> a[i] >> b[i];
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	ll db = 0, dba = 0;
	ll ans = 0;
	ll ai = 0, bi = 0;
	for(ll i = 1; i <= n; i++)
	{
		dba = db;
		while(a[ai] < i && ai+1 < a.size()) ai++;
		while(b[bi] < i && bi+1 < b.size()) bi++;
		while(ai < a.size() && a[ai] == i)
		{
			db++;
			ai++;
		}
		while(bi < b.size() && b[bi] == i)
		{
			db--;
			bi++;
		}
		if((dba != 0 || i == 1) && db == 0) ans++;
	}
	cout << ans << endl;
}
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll t = 1;
    	//cin >> t;
    	while(t--)
    	{
        	solve();
    	}
    	return 0;
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/03ms1824 KiB
2Wrong answer0/0103ms33152 KiB
3Accepted2/23ms2104 KiB
4Wrong answer0/23ms2236 KiB
5Accepted2/22ms2324 KiB
6Accepted2/23ms2448 KiB
7Accepted2/23ms2676 KiB
8Accepted2/23ms3024 KiB
9Wrong answer0/23ms3140 KiB
10Wrong answer0/23ms3348 KiB
11Accepted2/24ms5164 KiB
12Accepted2/27ms6432 KiB
13Wrong answer0/38ms6388 KiB
14Wrong answer0/316ms9268 KiB
15Wrong answer0/314ms9448 KiB
16Wrong answer0/386ms34936 KiB
17Wrong answer0/386ms34872 KiB
18Wrong answer0/390ms34872 KiB
19Wrong answer0/328ms16328 KiB
20Wrong answer0/335ms19668 KiB
21Wrong answer0/398ms35084 KiB
22Wrong answer0/3100ms35088 KiB