71392023-12-31 12:55:26IgnácÁruszállítás (75 pont)cpp17Accepted 75/7586ms5792 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> aruk(m);
	for (int i = 0; i < m; i++) {
		cin >> aruk[i].first >> aruk[i].second;
	}
	
	sort(aruk.begin(), aruk.end());
	int db = 0, veg = 1;
	for (int i = 0; i < m; i++) {
		if (aruk[i].first > veg) db += aruk[i].first - veg;
		veg = max(veg, aruk[i].second);
	}

	cout << db + n - veg;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1808 KiB
2Accepted0/086ms3424 KiB
3Accepted3/33ms2220 KiB
4Accepted3/33ms2428 KiB
5Accepted3/33ms2784 KiB
6Accepted3/33ms2928 KiB
7Accepted3/33ms3140 KiB
8Accepted4/43ms3120 KiB
9Accepted4/43ms3116 KiB
10Accepted4/43ms3180 KiB
11Accepted4/43ms3312 KiB
12Accepted4/43ms3400 KiB
13Accepted4/47ms3816 KiB
14Accepted4/48ms4044 KiB
15Accepted4/47ms3960 KiB
16Accepted4/48ms4236 KiB
17Accepted4/48ms4324 KiB
18Accepted4/49ms4268 KiB
19Accepted4/48ms4404 KiB
20Accepted4/49ms4496 KiB
21Accepted4/478ms5536 KiB
22Accepted4/482ms5792 KiB