72132024-01-03 16:43:47MagyarKendeSZLGTalálkozáscpp17Elfogadva 55/5537ms5052 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

const int INF = 100'000;

int main() {
	speed;

	int N;
	cin >> N;

	vector<int> beginS(N), endS(N);

	for (int i = 0; i < N; i++) {
		cin >> beginS[i] >> endS[i];
	}

	sort(all(beginS));
	sort(all(endS));	

	int
	H = N / 2 + (N & 1),
	curr = 0,
	begin = 0, 
	end = 0,
	mn_begin = -1,
	mn_end = -1,
	begin_i = 0,
	end_i = 0;

	for (; begin <= INF; begin++) {

		while ((end <= INF && curr < H) || begin == end) {
			while (begin_i < N && beginS[begin_i] == end) {
				begin_i++;
				curr++;
			}
			end++;
		}

		if (H <= curr && (mn_begin == -1 || end - begin < mn_end - mn_begin)) {
			mn_begin = begin;
			mn_end = end;
		}

		while (end_i < N && endS[end_i] == begin) {
			end_i++;
			curr--;
		}
	}

	cout 
	<< mn_end - mn_begin << '\n' 
	<< mn_begin << ' ' << mn_end - 1; 
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base55/55
1Elfogadva0/03ms1832 KiB
2Elfogadva0/037ms3516 KiB
3Elfogadva2/23ms2596 KiB
4Elfogadva2/23ms2556 KiB
5Elfogadva2/23ms2784 KiB
6Elfogadva2/23ms2908 KiB
7Elfogadva2/23ms3264 KiB
8Elfogadva3/33ms3012 KiB
9Elfogadva3/33ms3012 KiB
10Elfogadva3/33ms3160 KiB
11Elfogadva3/34ms3064 KiB
12Elfogadva3/36ms3248 KiB
13Elfogadva3/36ms3468 KiB
14Elfogadva3/38ms3608 KiB
15Elfogadva3/38ms3612 KiB
16Elfogadva3/38ms3628 KiB
17Elfogadva3/38ms3624 KiB
18Elfogadva3/313ms3768 KiB
19Elfogadva3/329ms4852 KiB
20Elfogadva3/326ms4900 KiB
21Elfogadva3/335ms5052 KiB
22Elfogadva3/335ms4908 KiB