73352024-01-07 20:46:32szabelrA lehető legkevesebb átszállás (50 pont)cpp17Wrong answer 14/50300ms4004 KiB
#include <iostream>
#include <algorithm>
using namespace std;
int jok[100001]{ 0 };
int tombkezd[100001]{ 0 };
int tombveg[100001]{ 0 };
int main()
{
    int n, m, kezd, veg, hol = 1, hova = 0, 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 (hol > max) { 
            max=hol;
        }
        
        if (valami == 0 or hol<max) {
            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] << " ";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Accepted0/03ms2032 KiB
2Wrong answer0/052ms2380 KiB
3Accepted1/13ms2416 KiB
4Accepted1/13ms2624 KiB
5Accepted2/23ms2624 KiB
6Accepted2/23ms2636 KiB
7Wrong answer0/23ms2912 KiB
8Wrong answer0/24ms2856 KiB
9Wrong answer0/24ms2988 KiB
10Wrong answer0/24ms3080 KiB
11Wrong answer0/212ms3088 KiB
12Wrong answer0/213ms3160 KiB
13Wrong answer0/24ms3192 KiB
14Wrong answer0/212ms3328 KiB
15Wrong answer0/214ms3352 KiB
16Wrong answer0/216ms3368 KiB
17Wrong answer0/239ms3520 KiB
18Wrong answer0/243ms3708 KiB
19Wrong answer0/243ms3880 KiB
20Wrong answer0/243ms3840 KiB
21Wrong answer0/248ms4004 KiB
22Wrong answer0/250ms4000 KiB
23Accepted2/248ms3920 KiB
24Accepted2/217ms3804 KiB
25Time limit exceeded0/2300ms2960 KiB
26Accepted2/223ms3768 KiB
27Accepted2/259ms3796 KiB
28Wrong answer0/2120ms3980 KiB