43972023-03-27 13:18:13AGergoTűzijátékcpp11Accepted 50/5043ms4640 KiB
#include <bits/stdc++.h>

using namespace std;

int telepszam,hely,tav,sum;
vector<int> haz;
vector<bool> tuz;

void elo(int index)
{
    for(int i = index+1; i < telepszam; i++)
    {
        if(haz[i] >= haz[index] + tav)
        {
            tuz[i] = true;
            elo(i);
            sum++;
            break;
        }
    }
}

void hat(int index)
{
    for(int i = index-1; i >= 0; i--)
    {
        if(haz[i] + tav <= haz[index])
        {
            tuz[i] = true;
            hat(i);
            sum++;
            break;
        }
    }
}
int main()
{

    cin >> telepszam >> hely >> tav;

    haz.resize(telepszam);
    tuz.resize(telepszam);

    tuz[hely-1] = true;


    for(int i = 0; i < telepszam; i++)
    {
        cin >> haz[i];
    }

    elo(hely-1);
    hat(hely-1);

    cout << sum+1 << "\n";
    for(int i = 0; i < telepszam; i++)
    {
        if(tuz[i])
        {
            cout << i+1 << " ";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1880 KiB
2Accepted0/041ms3064 KiB
3Accepted2/23ms2192 KiB
4Accepted2/22ms2260 KiB
5Accepted2/23ms2512 KiB
6Accepted2/22ms2472 KiB
7Accepted2/22ms2476 KiB
8Accepted2/23ms2616 KiB
9Accepted2/24ms2728 KiB
10Accepted2/26ms2884 KiB
11Accepted2/26ms3068 KiB
12Accepted2/28ms3440 KiB
13Accepted2/28ms3548 KiB
14Accepted2/28ms3652 KiB
15Accepted3/38ms3684 KiB
16Accepted3/313ms3816 KiB
17Accepted3/317ms3720 KiB
18Accepted3/320ms3860 KiB
19Accepted3/343ms4516 KiB
20Accepted3/343ms4504 KiB
21Accepted4/441ms4508 KiB
22Accepted4/443ms4640 KiB