59492023-10-06 09:37:45zsebiA lehető legkevesebb átszállás (50 pont)cpp11Elfogadva 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
RészfeladatÖsszpontTesztVerdiktIdőMemória
base50/50
1Elfogadva0/03ms1812 KiB
2Elfogadva0/09ms5096 KiB
3Elfogadva1/13ms2212 KiB
4Elfogadva1/12ms2424 KiB
5Elfogadva2/22ms2636 KiB
6Elfogadva2/22ms2760 KiB
7Elfogadva2/23ms3180 KiB
8Elfogadva2/23ms3392 KiB
9Elfogadva2/24ms3332 KiB
10Elfogadva2/24ms3464 KiB
11Elfogadva2/26ms4500 KiB
12Elfogadva2/26ms4992 KiB
13Elfogadva2/23ms4024 KiB
14Elfogadva2/24ms4944 KiB
15Elfogadva2/24ms5284 KiB
16Elfogadva2/26ms5360 KiB
17Elfogadva2/28ms6652 KiB
18Elfogadva2/28ms6612 KiB
19Elfogadva2/28ms7000 KiB
20Elfogadva2/28ms7204 KiB
21Elfogadva2/29ms7132 KiB
22Elfogadva2/29ms7196 KiB
23Elfogadva2/28ms6152 KiB
24Elfogadva2/29ms6548 KiB
25Elfogadva2/29ms7064 KiB
26Elfogadva2/29ms7300 KiB
27Elfogadva2/29ms7292 KiB
28Elfogadva2/29ms7624 KiB