59492023-10-06 09:37:45zsebiA lehető legkevesebb átszállás (50 pont)cpp11Accepted 50/509ms7624 KiB
// Berlet.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>

#define ll long long
using namespace std;

ll n, m;
int main()
{
	cin >> n >> m;
	vector<pair<ll,ll>>x(m + 1);
	vector<ll>ans;
	for (int i = 1; i <= n; ++i)
	{
		//ll a, b;
		cin >> x[i].first >> x[i].second;
	
	}
	int i = 1, veg = 1;
	while (veg<m)
	{
		ll akt = -1;
		while (i <= n && x[i].first <= veg)
		{
			if (akt == -1 || x[i].second > x[akt].second)
			{
				akt = i;
				
			}
			++i;
		}
		
		if (akt == -1)
		{
			cout<<"-1";
			return 0;
		}
		else
		{
			veg = x[akt].second;
			ans.push_back(akt);
		}

	}
	cout << ans.size() - 1<<"\n";
	for (auto& e : ans)cout << e << " ";
   return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/09ms5096 KiB
3Accepted1/13ms2212 KiB
4Accepted1/12ms2424 KiB
5Accepted2/22ms2636 KiB
6Accepted2/22ms2760 KiB
7Accepted2/23ms3180 KiB
8Accepted2/23ms3392 KiB
9Accepted2/24ms3332 KiB
10Accepted2/24ms3464 KiB
11Accepted2/26ms4500 KiB
12Accepted2/26ms4992 KiB
13Accepted2/23ms4024 KiB
14Accepted2/24ms4944 KiB
15Accepted2/24ms5284 KiB
16Accepted2/26ms5360 KiB
17Accepted2/28ms6652 KiB
18Accepted2/28ms6612 KiB
19Accepted2/28ms7000 KiB
20Accepted2/28ms7204 KiB
21Accepted2/29ms7132 KiB
22Accepted2/29ms7196 KiB
23Accepted2/28ms6152 KiB
24Accepted2/29ms6548 KiB
25Accepted2/29ms7064 KiB
26Accepted2/29ms7300 KiB
27Accepted2/29ms7292 KiB
28Accepted2/29ms7624 KiB