97012024-03-01 12:10:29GervidHadjáratcpp17Time limit exceeded 0/100300ms5268 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

	vector<pair<pair<int, int>, int>> a(n);
	for (i = 0; i < n; i++)
	{
		cin >> a[i].first.first >> a[i].first.second;
		a[i].second = i;
	}

	sort(a.begin(), a.end());

	vector<int> opt(n);
	opt[0] = 1;

	vector<int> last(n, -1);

	for (i = 1; i < n; i++)
	{
		int best = 0;
		for (j = i-1; j >= 0; j--)
		{
			if (a[j].first.first < a[i].first.first && a[j].first.second < a[i].first.second && opt[j] > best)
			{
				best = opt[j];
				last[i] = j;
			}
		}

		opt[i] = best + 1;
	}

	int max = 0, maxi;
	for (i = 0; i < n; i++)
	{
		if (opt[i] > max)
		{
			max = opt[i];
			maxi = i;
		}
	}

	cout << max << '\n';

	i = maxi;
	vector<int> out;
	out.reserve(max);

	while (i != -1)
	{
		out.push_back(i);
		i = last[i];
	}

	for (i = max-1; i >= 0; i--)
	{
		cout << a[out[i]].second + 1 << ' ';
	}
}
SubtaskSumTestVerdictTimeMemory
base0/100
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0263ms2300 KiB
3Wrong answer0/43ms2288 KiB
4Wrong answer0/43ms2500 KiB
5Wrong answer0/43ms2640 KiB
6Wrong answer0/43ms2856 KiB
7Wrong answer0/43ms3068 KiB
8Wrong answer0/43ms3200 KiB
9Wrong answer0/43ms3256 KiB
10Wrong answer0/46ms3272 KiB
11Wrong answer0/468ms3608 KiB
12Time limit exceeded0/4261ms4048 KiB
13Time limit exceeded0/6259ms4104 KiB
14Time limit exceeded0/6268ms3284 KiB
15Time limit exceeded0/6273ms3456 KiB
16Time limit exceeded0/6300ms3912 KiB
17Time limit exceeded0/6268ms4124 KiB
18Time limit exceeded0/6252ms4236 KiB
19Time limit exceeded0/6273ms4456 KiB
20Time limit exceeded0/6266ms4888 KiB
21Time limit exceeded0/6259ms5144 KiB
22Time limit exceeded0/6270ms5268 KiB