64452023-11-30 15:47:17gergomiszoriÁruszállítás üres szakaszaicpp17Wrong answer 34/50104ms35372 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 && 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
base34/50
1Accepted0/03ms1824 KiB
2Accepted0/0104ms33156 KiB
3Wrong answer0/23ms2276 KiB
4Wrong answer0/23ms2500 KiB
5Wrong answer0/23ms2692 KiB
6Wrong answer0/22ms2780 KiB
7Wrong answer0/23ms3020 KiB
8Wrong answer0/23ms3216 KiB
9Accepted2/23ms3432 KiB
10Accepted2/23ms3476 KiB
11Wrong answer0/24ms5356 KiB
12Wrong answer0/28ms6608 KiB
13Accepted3/39ms6668 KiB
14Accepted3/316ms9476 KiB
15Accepted3/314ms9396 KiB
16Accepted3/386ms34888 KiB
17Accepted3/386ms35156 KiB
18Accepted3/394ms35372 KiB
19Accepted3/328ms16744 KiB
20Accepted3/334ms19824 KiB
21Accepted3/3103ms35356 KiB
22Accepted3/3104ms35352 KiB