213052026-01-12 18:12:46PappMatyasTalálkozáscpp17Wrong answer 50/5571ms1384 KiB
#include <iostream>
#include <vector>

using namespace std;

const int maxLength = 100000;

int main()
{
	int n;
	vector<int> starts(maxLength, 0);
	vector<int> ends(maxLength, 0);

	cin >> n;

	int lastDay = 0;

	for (int i = 0; i < n; i++)
	{
		int s, e;
		cin >> s >> e;
		starts[s - 1]++;
		ends[e - 1]++;
		lastDay = max(lastDay, e);
	}

	int ce = 0, total = starts[0];

	int minimum = maxLength + 1;

	int se = -1;
	int ss = -1;

	float threshold = float(n) / 2;

	for (int i = 0; i < lastDay; i++)
	{
		while (total < threshold && ce < lastDay)
		{
			ce++;
			total += starts[ce];
		}
		if (ce - i + 1 < minimum && total >= threshold)
		{
			minimum = ce - i + 1;
			se = ce + 1;
			ss = i + 1;
		}
		total -= ends[i];
	}

	cout << minimum << endl << ss << " " << se << endl;

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/55
1Accepted0/01ms1076 KiB
2Accepted0/068ms1076 KiB
3Wrong answer0/22ms1076 KiB
4Accepted2/21ms1076 KiB
5Accepted2/22ms1076 KiB
6Accepted2/22ms1076 KiB
7Accepted2/22ms1076 KiB
8Accepted3/32ms984 KiB
9Accepted3/32ms1044 KiB
10Accepted3/32ms1076 KiB
11Accepted3/36ms1076 KiB
12Accepted3/38ms1196 KiB
13Accepted3/38ms1384 KiB
14Accepted3/314ms1076 KiB
15Accepted3/314ms1212 KiB
16Accepted3/314ms1076 KiB
17Accepted3/313ms1076 KiB
18Accepted3/323ms1076 KiB
19Wrong answer0/371ms1076 KiB
20Accepted3/364ms1192 KiB
21Accepted3/368ms1076 KiB
22Accepted3/368ms1272 KiB