73362024-01-07 21:00:10szabelrA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 14/50300ms4760 KiB
// A lehető legkevesebb átszállá.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <algorithm>
using namespace std;
int jok[1000001]{ 0 };
int tombkezd[1000001]{ 0 };
int tombveg[1000001]{ 0 };

int main()
{
    int n, m, kezd, veg, hol = 1,  jo, valami=0,max=0,z=1,db=0,t=1,ln=0;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) 
    {
        cin >> kezd >> veg;
        tombkezd[i] = kezd;
        tombveg[i] = veg;
        if (veg > ln) {
            ln = veg;
        }
    }
    if (ln < m) {
        cout << "-1";
    }
    while (hol < m) 
    {   
        valami = 0;
        for (int i = 1; i <= n; i++) {
            if (tombkezd[i] == hol and tombveg[i]>max) {
                valami = 1;
                max = tombveg[i];
                jo = i;
            }
        }
        hol = max;
        if (valami == 0) {
            hol=max-z;
            z++;
        }
        if (valami == 1) {
            jok[t] = jo;
            t++;
            z = 1;
        }
        if (hol <= 0) {
            cout << "-1";
            break;
        }
    }
    if (hol > 0) {
        cout << t - 2 << endl;
        for (int alma = 1; alma <= t - 1; alma++) {
            cout << jok[alma] << " ";
        }
    }
}

// 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
base14/50
1Accepted0/03ms2164 KiB
2Wrong answer0/052ms2576 KiB
3Accepted1/13ms2504 KiB
4Accepted1/13ms2604 KiB
5Accepted2/23ms2724 KiB
6Accepted2/23ms2936 KiB
7Wrong answer0/23ms3120 KiB
8Wrong answer0/24ms3404 KiB
9Wrong answer0/24ms3384 KiB
10Wrong answer0/26ms3428 KiB
11Wrong answer0/212ms3528 KiB
12Wrong answer0/213ms3596 KiB
13Wrong answer0/24ms3420 KiB
14Wrong answer0/212ms3568 KiB
15Wrong answer0/214ms3428 KiB
16Wrong answer0/216ms3444 KiB
17Wrong answer0/239ms3464 KiB
18Wrong answer0/241ms3760 KiB
19Wrong answer0/243ms3764 KiB
20Wrong answer0/245ms4332 KiB
21Wrong answer0/248ms4200 KiB
22Wrong answer0/250ms4188 KiB
23Accepted2/248ms4184 KiB
24Accepted2/217ms4460 KiB
25Time limit exceeded0/2300ms3744 KiB
26Accepted2/223ms4708 KiB
27Accepted2/259ms4560 KiB
28Wrong answer0/2120ms4760 KiB