84722024-01-17 11:44:34GervidMekk Mester munkái (50 pont)cpp17Accepted 50/5086ms7724 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct job
{
	int start, end, number;
};

int main()
{
	int n, h, i;
	cin >> n >> h;

	vector<job> jobs(n);

	for (i = 0; i < n; i++)
	{
		jobs[i].number = i;
		cin >> jobs[i].start >> jobs[i].end;
	}

	int mlast = 0, flast = 0;
	vector<int> m, f;

	sort(jobs.begin(), jobs.end(), [](job a, job b) {
		if (a.end == b.end)
		{
			return a.start < b.start;
		}
		return a.end < b.end;
		});

	for (i = 0; i < n; i++)
	{
		int start = jobs[i].start, end = jobs[i].end, number = jobs[i].number;

		if (mlast < flast)
		{
			if (flast < start)
			{
				f.push_back(number);
				flast = end;
			}
			else
			{
				if (mlast < start)
				{
					m.push_back(number);
					mlast = end;
				}
			}
		}
		else
		{
			if (mlast < start)
			{
				m.push_back(number);
				mlast = end;
			}
			else
			{
				if (flast < start)
				{
					f.push_back(number);
					flast = end;
				}
			}

		}
	}

	cout << m.size() << ' ' << f.size() << endl;

	for (i = 0; i < m.size(); i++)
	{
		cout << m[i] + 1 << ' ';
	}
	cout << endl;

	for (i = 0; i < f.size(); i++)
	{
		cout << f[i] + 1 << ' ';
	}
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/08ms2400 KiB
3Accepted1/13ms2300 KiB
4Accepted1/13ms2532 KiB
5Accepted2/23ms2648 KiB
6Accepted2/23ms2736 KiB
7Accepted2/23ms2728 KiB
8Accepted2/23ms2860 KiB
9Accepted3/33ms3068 KiB
10Accepted1/14ms3336 KiB
11Accepted1/13ms3428 KiB
12Accepted2/23ms3688 KiB
13Accepted2/23ms3796 KiB
14Accepted2/23ms3760 KiB
15Accepted2/23ms3808 KiB
16Accepted3/33ms3936 KiB
17Accepted2/283ms6664 KiB
18Accepted2/278ms6484 KiB
19Accepted4/478ms6840 KiB
20Accepted4/478ms6592 KiB
21Accepted4/478ms6560 KiB
22Accepted4/481ms6760 KiB
23Accepted4/486ms7724 KiB