7672022-01-10 07:28:55kidesoÁruszállítás (75 pont)cpp11Accepted 75/75101ms14524 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, K;
	cin >> N >> K;
	vector <int> x(N + 2, 0);

	int a, b;
	for (int i = 1; i <= K; ++i)
	{
		cin >> a >> b;
		++x[a];
		--x[b];
	}

	for (int i = 1; i <= N; ++i)
		x[i] += x[i - 1];

	x[N] = 1;
	int db = 0, a_db = 0;
	
	/*for (auto e : x) cout << e << ' ';
	cout << '\n';*/

	for (int i = 1; i <= N; ++i)
	{
		if (x[i] == 0) ++a_db;
		else
		{
			if (a_db != 0) db+=a_db;
			a_db = 0;
		}
	}

	cout << db << '\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/02ms1744 KiB
2Accepted0/0101ms11000 KiB
3Accepted3/31ms3296 KiB
4Accepted3/31ms3292 KiB
5Accepted3/31ms3300 KiB
6Accepted3/31ms3304 KiB
7Accepted3/31ms3312 KiB
8Accepted4/41ms3308 KiB
9Accepted4/41ms3316 KiB
10Accepted4/41ms3324 KiB
11Accepted4/42ms3540 KiB
12Accepted4/42ms3668 KiB
13Accepted4/46ms3804 KiB
14Accepted4/48ms4788 KiB
15Accepted4/46ms4900 KiB
16Accepted4/48ms6008 KiB
17Accepted4/48ms6756 KiB
18Accepted4/49ms7776 KiB
19Accepted4/48ms6988 KiB
20Accepted4/410ms8020 KiB
21Accepted4/475ms13088 KiB
22Accepted4/479ms14524 KiB