64492023-11-30 16:03:16gergomiszoriÁruszállítás üres szakaszaicpp17Wrong answer 48/5054ms7136 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(m), b(m);
	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;
	bool ures = false;
	ll ans = 0;
	ll ai = 0, bi = 0;
	for(ll i = 1; i <= n; i++)
	{
		if(!ures && db == 0) 
		{
			ans++;
			ures = true;
		}
		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++;
			ures = false;
		}
		while(bi < b.size() && b[bi] == i)
		{
			db--;
			bi++;
			ures = false;
		}
	}
	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
base48/50
1Wrong answer0/03ms1824 KiB
2Accepted0/054ms5088 KiB
3Accepted2/23ms2364 KiB
4Wrong answer0/23ms2488 KiB
5Accepted2/23ms2704 KiB
6Accepted2/22ms2784 KiB
7Accepted2/23ms2904 KiB
8Accepted2/23ms2952 KiB
9Accepted2/23ms3080 KiB
10Accepted2/23ms3288 KiB
11Accepted2/23ms3376 KiB
12Accepted2/23ms3612 KiB
13Accepted3/34ms3792 KiB
14Accepted3/37ms4072 KiB
15Accepted3/36ms4232 KiB
16Accepted3/335ms6476 KiB
17Accepted3/335ms6616 KiB
18Accepted3/341ms6980 KiB
19Accepted3/38ms4368 KiB
20Accepted3/38ms4368 KiB
21Accepted3/350ms7136 KiB
22Accepted3/350ms7092 KiB