102082024-03-29 14:14:29VargusA lehető legkevesebb átszállás (50 pont)cpp17Accepted 50/509ms5220 KiB
#include <iostream>
#include <queue>
#define ll long long

using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    vector <ll> a(n + 1), b(n + 1);
    vector <ll> poz;
    for (ll i = 1; i <= n; ++i)
    {
        cin >> a[i] >> b[i];
    }

    ll i = 1, veg = 1;
    while (veg < m)
    {
        ll akt = -1;
        while (i <= n && a[i] <= veg)
        {
            if (akt == -1 || b[i] > b[akt])
            {
                akt = i;
            }
            ++i;
        }
        if (akt == -1)
        {
            cout << "-1";
            return 0;
        }
        else
        {
            veg = b[akt];
            poz.push_back(akt);
        }
    }
    cout << poz.size() - 1 << endl;
    for (auto& e : poz)
        cout << e << " ";

    return 0;
}
/*
6 9
1 4
1 6
2 6
3 4
6 8
7 9
*/
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1816 KiB
2Accepted0/09ms2340 KiB
3Accepted1/13ms2264 KiB
4Accepted1/13ms2472 KiB
5Accepted2/23ms2724 KiB
6Accepted2/23ms2916 KiB
7Accepted2/23ms3144 KiB
8Accepted2/24ms3352 KiB
9Accepted2/24ms3572 KiB
10Accepted2/24ms3652 KiB
11Accepted2/24ms3988 KiB
12Accepted2/26ms4248 KiB
13Accepted2/23ms4272 KiB
14Accepted2/24ms4516 KiB
15Accepted2/24ms4596 KiB
16Accepted2/26ms4624 KiB
17Accepted2/27ms4656 KiB
18Accepted2/28ms4796 KiB
19Accepted2/28ms4928 KiB
20Accepted2/28ms4928 KiB
21Accepted2/28ms5060 KiB
22Accepted2/29ms5048 KiB
23Accepted2/28ms4928 KiB
24Accepted2/28ms4932 KiB
25Accepted2/28ms5072 KiB
26Accepted2/28ms4928 KiB
27Accepted2/28ms4940 KiB
28Accepted2/28ms5220 KiB