7976 2024. 01. 12 09:35:23 250L7 A lehető legkevesebb átszállás (50 pont) cpp17 Futási hiba 49/50 50ms 64424 KiB
// vonat.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;

int main()
{
	int vonat, allom;
	cin >> vonat >> allom;
	vector <pair<int, int>> megall(vonat);
	for (int i = 0; i < vonat; i++)
	{
		cin >> megall[i].first >> megall[i].second;
	}
	int helymax = 1;
	int x = 0;
	int atszall = 0;
	int maxi = 0, maxihely = 0;
	vector <int> ut;
	while (x < vonat && helymax != allom)
	{
		//cout << "n";
		while (x < vonat && megall[x].first <= helymax)
		{
			if (megall[x].second > maxi)
			{
				maxi = megall[x].second;
				maxihely = x;
			}
			x++;
		}
		helymax = maxi;
		ut.push_back(maxihely+1);
		atszall++;
	}
	if (helymax == allom)
	{
		cout << atszall - 1 << endl;
		for (int i = 0; i < ut.size(); i++)
		{
			cout << ut[i] << " ";
		}
	}
	else {
		cout << "-1";
	}
}

// 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 Összpont Teszt Verdikt Idő Memória
base 49/50
1 Elfogadva 0/0 3ms 1816 KiB
2 Elfogadva 0/0 8ms 2260 KiB
3 Elfogadva 1/1 3ms 2340 KiB
4 Futási hiba 0/1 50ms 64424 KiB
5 Elfogadva 2/2 3ms 2528 KiB
6 Elfogadva 2/2 3ms 2540 KiB
7 Elfogadva 2/2 3ms 2832 KiB
8 Elfogadva 2/2 3ms 3012 KiB
9 Elfogadva 2/2 4ms 2980 KiB
10 Elfogadva 2/2 4ms 3180 KiB
11 Elfogadva 2/2 4ms 3200 KiB
12 Elfogadva 2/2 6ms 3216 KiB
13 Elfogadva 2/2 3ms 3176 KiB
14 Elfogadva 2/2 4ms 3316 KiB
15 Elfogadva 2/2 4ms 3408 KiB
16 Elfogadva 2/2 6ms 3428 KiB
17 Elfogadva 2/2 8ms 3696 KiB
18 Elfogadva 2/2 8ms 3920 KiB
19 Elfogadva 2/2 8ms 4132 KiB
20 Elfogadva 2/2 8ms 4092 KiB
21 Elfogadva 2/2 8ms 4100 KiB
22 Elfogadva 2/2 8ms 4100 KiB
23 Elfogadva 2/2 8ms 4396 KiB
24 Elfogadva 2/2 8ms 4340 KiB
25 Elfogadva 2/2 8ms 4304 KiB
26 Elfogadva 2/2 8ms 4564 KiB
27 Elfogadva 2/2 8ms 4516 KiB
28 Elfogadva 2/2 8ms 4516 KiB